forked from MaxFedotov/orcus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
http.go
30 lines (25 loc) · 777 Bytes
/
http.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package main
import (
"crypto/tls"
"net"
"net/http"
log "github.com/sirupsen/logrus"
)
var httpClient *http.Client
// InitHTTPClient initializes new httpClient according to configuraion
func InitHTTPClient(HTTPTimeout Duration, SSLSkipVerify bool) {
log.WithFields(log.Fields{
"HTTPTimeout": HTTPTimeout,
"SSLSkipVerify": SSLSkipVerify,
}).Debug("Initializing http client")
timeout := HTTPTimeout.Duration
dialTimeout := func(network, addr string) (net.Conn, error) {
return net.DialTimeout(network, addr, timeout)
}
httpTransport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: SSLSkipVerify},
Dial: dialTimeout,
ResponseHeaderTimeout: timeout,
}
httpClient = &http.Client{Transport: httpTransport}
}