Skip to content

Commit

Permalink
Add ability to set a custom http client on the client
Browse files Browse the repository at this point in the history
  • Loading branch information
kishiyama committed May 23, 2023
1 parent 250914c commit bce5080
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions fc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ func NewFullContactClient(options ...ClientOption) (*fullContactClient, error) {
if c.retryHandler == nil {
c.retryHandler = &DefaultRetryHandler{}
}
c.httpClient = &http.Client{
Timeout: time.Duration(c.connectTimeoutMillis) * time.Millisecond,

if c.httpClient == nil {
c.httpClient = &http.Client{
Timeout: time.Duration(c.connectTimeoutMillis) * time.Millisecond,
}
}

return c, nil
Expand Down Expand Up @@ -71,3 +74,9 @@ func WithRetryHandler(retryHandler RetryHandler) ClientOption {
fc.retryHandler = retryHandler
}
}

func WithHTTPClient(httpClient *http.Client) ClientOption {
return func(fc *fullContactClient) {
fc.httpClient = httpClient
}
}

0 comments on commit bce5080

Please sign in to comment.