Skip to content

Commit c97bce3

Browse files
authored
Merge pull request #11 from webconnex/custom-http-client
Add ability to use a custom http client
2 parents dad44cf + bce5080 commit c97bce3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

fc/client.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ func NewFullContactClient(options ...ClientOption) (*fullContactClient, error) {
3939
if c.retryHandler == nil {
4040
c.retryHandler = &DefaultRetryHandler{}
4141
}
42-
c.httpClient = &http.Client{
43-
Timeout: time.Duration(c.connectTimeoutMillis) * time.Millisecond,
42+
43+
if c.httpClient == nil {
44+
c.httpClient = &http.Client{
45+
Timeout: time.Duration(c.connectTimeoutMillis) * time.Millisecond,
46+
}
4447
}
4548

4649
return c, nil
@@ -71,3 +74,9 @@ func WithRetryHandler(retryHandler RetryHandler) ClientOption {
7174
fc.retryHandler = retryHandler
7275
}
7376
}
77+
78+
func WithHTTPClient(httpClient *http.Client) ClientOption {
79+
return func(fc *fullContactClient) {
80+
fc.httpClient = httpClient
81+
}
82+
}

0 commit comments

Comments
 (0)