diff --git a/README.md b/README.md index 5d3a7e6..fa171af 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ information. validation behavior - Configurable timeouts - Configurable retry support +- Support for overriding the default `http.Client` ## Project Status diff --git a/doc.go b/doc.go index c96a8e0..81ce0f1 100644 --- a/doc.go +++ b/doc.go @@ -33,6 +33,8 @@ FEATURES • Configurable retry support +• Support for overriding the default http.Client + USAGE diff --git a/send.go b/send.go index 88188e9..8b3953f 100644 --- a/send.go +++ b/send.go @@ -89,6 +89,7 @@ type API interface { Send(webhookURL string, webhookMessage MessageCard) error SendWithContext(ctx context.Context, webhookURL string, webhookMessage MessageCard) error SendWithRetry(ctx context.Context, webhookURL string, webhookMessage MessageCard, retries int, retriesDelay int) error + SetHTTPClient(httpClient *http.Client) API SkipWebhookURLValidationOnSend(skip bool) API AddWebhookURLValidationPatterns(patterns ...string) API ValidateWebhook(webhookURL string) error @@ -133,6 +134,14 @@ func NewClient() API { return &client } +// SetHTTPClient accepts a custom http.Client value which replaces the +// existing default http.Client. +func (c *teamsClient) SetHTTPClient(httpClient *http.Client) API { + c.httpClient = httpClient + + return c +} + func (c *teamsClient) AddWebhookURLValidationPatterns(patterns ...string) API { c.webhookURLValidationPatterns = append(c.webhookURLValidationPatterns, patterns...) return c