package httpclient import ( "crypto/tls" "github.com/go-resty/resty/v2" "time" ) const ( ContentType = "Content-Type" ApplicationJson = "application/json" MutipartFormData = "multipart/form-data; boundary=" ApplicationFromUrlencoded = "application/x-www-from-urlencoded" ) var httpClient *resty.Client = nil var httpsClient *resty.Client = nil func NewHttpClient() *resty.Client { if httpClient != nil { return httpClient } httpClient = resty.New() httpClient.SetTimeout(5 * time.Second) httpClient.SetRetryCount(3) //debug := config.GetConfig("httpclient.debug") debug := "ture" if len(debug) > 0 && debug == "ON" { httpClient.SetDebug(true) } return httpClient } func NewHttpsClient() *resty.Client { if httpsClient != nil { return httpsClient } c := resty.New() c.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) c.SetTimeout(5 * time.Second) c.SetRetryCount(3) //debug := config.GetConfig("httpclient.debug") debug := "ture" if len(debug) > 0 && debug == "ON" { c.SetDebug(true) } httpsClient = c return c }