diff --git a/client_options.go b/client_options.go index fe1196a..13c562d 100644 --- a/client_options.go +++ b/client_options.go @@ -1,5 +1,7 @@ package tapd +import "net/http" + type ClientOption func(*Client) error // WithBaseURL sets the baseURL for the client @@ -24,3 +26,10 @@ func WithUserAgent(userAgent string) ClientOption { return nil } } + +func WithHTTPClient(httpClient *http.Client) ClientOption { + return func(c *Client) error { + c.httpClient = httpClient + return nil + } +} diff --git a/client_options_http_client.go b/client_options_http_client.go index ca6c78e..1f465e4 100644 --- a/client_options_http_client.go +++ b/client_options_http_client.go @@ -47,7 +47,7 @@ func WithRetryableHTTPClientBackoff(backoff retryablehttp.Backoff) RetryableHTTP func NewRetryableHTTPClient(opts ...RetryableHTTPClientOption) *http.Client { retryClient := retryablehttp.NewClient() - // retryClient.Logger = nil // todo: set default logger + retryClient.Logger = nil for _, opt := range opts { opt(retryClient) } diff --git a/client_test.go b/client_test.go index dd2d6f4..c8871c4 100644 --- a/client_test.go +++ b/client_test.go @@ -3,6 +3,7 @@ package tapd import ( "context" "fmt" + "log" "net/http" "net/http/httptest" "os" @@ -17,7 +18,13 @@ func createServerClient(t *testing.T, handler http.Handler) (*httptest.Server, * srv := httptest.NewServer(handler) t.Cleanup(srv.Close) - client, err := NewClient("tapd-username", "tapd-password", WithBaseURL(srv.URL)) + client, err := NewClient( + "tapd-username", "tapd-password", + WithBaseURL(srv.URL), + WithHTTPClient(NewRetryableHTTPClient( + WithRetryableHTTPClientLogger(log.New(os.Stderr, "", log.LstdFlags)), + )), + ) assert.NoError(t, err) return srv, client