forked from yiigo/sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
46 lines (41 loc) · 1.06 KB
/
client.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package internal
import (
"crypto/tls"
"net"
"net/http"
"time"
"github.com/go-resty/resty/v2"
)
const (
HeaderAccept = "Accept"
HeaderAuthorization = "Authorization"
HeaderContentType = "Content-Type"
)
const (
ContentText = "text/plain; charset=utf-8"
ContentJSON = "application/json"
ContentXML = "application/xml"
ContentForm = "application/x-www-form-urlencoded"
ContentStream = "application/octet-stream"
ContentMultipartForm = "multipart/form-data"
)
func NewClient() *resty.Client {
return resty.NewWithClient(&http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 60 * time.Second,
}).DialContext,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
MaxIdleConns: 0,
MaxIdleConnsPerHost: 1000,
MaxConnsPerHost: 1000,
IdleConnTimeout: 60 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
},
})
}