Possibility to replace HTTP client inside Engine

This commit is contained in:
Pavel 2019-10-24 16:44:28 +03:00
parent 4e50a20a3c
commit 37a4c72a4b
2 changed files with 11 additions and 2 deletions

View File

@ -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 {

View File

@ -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 {