resty_v2 -> resty_v3

This commit is contained in:
2025-05-07 21:42:48 +08:00
parent 6dcd072570
commit ba47891d3c
11 changed files with 46 additions and 79 deletions

View File

@ -8,15 +8,14 @@
package httpclient
import (
"encoding/json"
"git.zhangdeman.cn/zhangdeman/consts"
"git.zhangdeman.cn/zhangdeman/network/httpclient/define"
"git.zhangdeman.cn/zhangdeman/serialize"
"git.zhangdeman.cn/zhangdeman/wrapper"
"github.com/go-resty/resty/v2"
"github.com/tidwall/gjson"
"net/http"
"net/textproto"
"resty.dev/v3"
"strings"
)
@ -31,15 +30,16 @@ func NewRestyClient(reqConfig *define.Request) (*resty.Client, *resty.Request) {
if nil == reqConfig {
return client, request
}
if nil != reqConfig.RateLimiter {
/*if nil != reqConfig.RateLimiter {
// 设置流控实例
client.SetRateLimiter(reqConfig.RateLimiter)
}
}*/
formatHeader(reqConfig)
client.SetAllowGetMethodPayload(true) // 配置 GET 请求允许带 Body
client.SetJSONMarshaler(json.Marshal) // 序列化方法
client.SetJSONEscapeHTML(true) // 处理html实体字符
client.SetJSONUnmarshaler(serialize.JSON.UnmarshalWithNumber) // 序列化方法
client.SetAllowMethodGetPayload(true) // 配置 GET 请求允许带 Body
client.SetAllowMethodDeletePayload(true) // 配置 DELETE 请求允许带 Body
client.SetJSONEscapeHTML(true) // 处理html实体字符
/*client.SetJSONMarshaler(json.Marshal) // 序列化方法
client.SetJSONUnmarshaler(serialize.JSON.UnmarshalWithNumber) // 反序列化方法*/
request.SetPathParams(reqConfig.PathParam) // 设置path中的参数
query := map[string]string{}