Skip to content

Commit

Permalink
Merge pull request #11 from webconnex/custom-http-client
Browse files Browse the repository at this point in the history
Add ability to use a custom http client
  • Loading branch information
nathan-pr authored Jun 29, 2023
2 parents dad44cf + bce5080 commit c97bce3
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 c97bce3

Please sign in to comment.