From bce50803e6de65a9984938d2259c1ca451fa5103 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 23 May 2023 15:58:21 -0700 Subject: [PATCH] Add ability to set a custom http client on the client --- fc/client.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fc/client.go b/fc/client.go index f52d22e..514f392 100644 --- a/fc/client.go +++ b/fc/client.go @@ -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 @@ -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 + } +}