Skip to content

Commit

Permalink
add spellcheck toggle option (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpedrie authored Mar 5, 2024
1 parent 58268c0 commit 5a16613
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
42 changes: 25 additions & 17 deletions brave.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,30 +187,31 @@ const (
type SearchOption func(searchOptions) searchOptions

type searchOptions struct {
country string
lang string
uiLang string
count int
offset int
safesearch Safesearch
freshness Freshness
country string
customFreshness []time.Time
textDecorations bool
resultFilter []ResultFilter
gogglesID string
units UnitType
extraSnippets bool
rich bool
noCache bool
userAgent string
freshness Freshness
gogglesID string
lang string
locCity string
locCountry string
locLatitude *float32
locLongitude *float32
locTimezone *time.Location
locCity string
locPostalCode string
locState string
locStateName string
locCountry string
locPostalCode string
locTimezone *time.Location
noCache bool
offset int
resultFilter []ResultFilter
rich bool
safesearch Safesearch
spellcheck *bool
textDecorations bool
uiLang string
units UnitType
userAgent string
}

func (s searchOptions) getFreshness() string {
Expand Down Expand Up @@ -637,6 +638,13 @@ func WithLocPostalCode(v string) SearchOption {
}
}

func WithSpellcheck(v bool) SearchOption {
return func(o searchOptions) searchOptions {
o.spellcheck = &v
return o
}
}

// ClientOption allows configuration of the API client.
type ClientOption func(clientOptions) clientOptions

Expand Down
2 changes: 2 additions & 0 deletions web.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type webSearchParams struct {
ResultFilter []string `url:"result_filter,omitempty,comma"`
Safesearch string `url:"safesearch,omitempty"`
SearchLang string `url:"search_lang,omitempty"`
Spellcheck *bool `url:"spellcheck,omitempty"`
Term string `url:"q"`
TextDecorations bool `url:"text_decorations,omitempty"`
UILang string `url:"ui_lang,omitempty"`
Expand All @@ -73,6 +74,7 @@ func (w *webSearchParams) fromSearchOptions(term string, options searchOptions)
w.ResultFilter = options.getResultFilter()
w.Safesearch = options.safesearch.String()
w.SearchLang = options.lang
w.Spellcheck = options.spellcheck
w.Term = term
w.TextDecorations = options.textDecorations
w.UILang = options.uiLang
Expand Down

0 comments on commit 5a16613

Please sign in to comment.