From 37a4c72a4b7e0c0f064466583a8e28f3beba8498 Mon Sep 17 00:00:00 2001 From: Pavel Date: Thu, 24 Oct 2019 16:44:28 +0300 Subject: [PATCH] Possibility to replace HTTP client inside Engine --- core/engine.go | 9 +++++++++ core/http_client_builder.go | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/core/engine.go b/core/engine.go index ae98a07..057809d 100644 --- a/core/engine.go +++ b/core/engine.go @@ -139,6 +139,15 @@ func (e *Engine) BuildHTTPClient(replaceDefault ...bool) *Engine { return e } +// SetHTTPClient sets HTTP client to engine +func (e *Engine) SetHTTPClient(client *http.Client) *Engine { + if client != nil { + e.httpClient = client + } + + return e +} + // HTTPClient returns inner http client or default http client func (e *Engine) HTTPClient() *http.Client { if e.httpClient == nil { diff --git a/core/http_client_builder.go b/core/http_client_builder.go index 41a0be3..2b53b4c 100644 --- a/core/http_client_builder.go +++ b/core/http_client_builder.go @@ -117,8 +117,8 @@ func (b *HTTPClientBuilder) FromConfig(config *HTTPClientConfig) *HTTPClientBuil } if config.MockAddress != "" { - b.mockAddress = config.MockAddress - b.mockedDomains = config.MockedDomains + b.SetMockAddress(config.MockAddress) + b.SetMockedDomains(config.MockedDomains) } if config.Timeout > 0 {