Refactor: move http client to the separate package

This commit is contained in:
Alexander Zobnin
2020-08-28 11:48:06 +03:00
parent 129705d39b
commit 2dc514db3a
2 changed files with 31 additions and 24 deletions

View File

@@ -0,0 +1,29 @@
package httpclient
import (
"crypto/tls"
"net"
"net/http"
"time"
)
// NewHttpClient returns new http client
func NewHttpClient() *http.Client {
return &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
Renegotiation: tls.RenegotiateFreelyAsClient,
},
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
},
Timeout: time.Duration(time.Second * 30),
}
}