// Package httpclient ... // // Description : httpclient ... // // Author : go_developer@163.com<白茶清欢> // // Date : 2024-05-31 14:59 package httpclient import ( "git.zhangdeman.cn/gateway/httpclient/define" "github.com/go-resty/resty/v2" "net/textproto" ) // NewRestyClient 获取resty client // // Author : go_developer@163.com<白茶清欢> // // Date : 15:00 2024/5/31 func NewRestyClient(requestConfig *define.Request) *resty.Client { formatHeader(requestConfig) client := resty.New() if nil == requestConfig { return client } return client } // formatHeader 格式化header // // Author : go_developer@163.com<白茶清欢> // // Date : 15:18 2024/5/31 func formatHeader(requestConfig *define.Request) { if nil == requestConfig { return } formatHeaderData := make(map[string]string) for headerName, headerVal := range requestConfig.Header { formatHeaderData[textproto.CanonicalMIMEHeaderKey(headerName)] = headerVal } requestConfig.Header = formatHeaderData }