修复path param处理的BUG

This commit is contained in:
白茶清欢 2025-05-07 21:59:25 +08:00
parent ba47891d3c
commit e02ee1fef9

View File

@ -59,12 +59,8 @@ func NewRestyClient(reqConfig *define.Request) (*resty.Client, *resty.Request) {
}
request.SetHeaders(header) // 设置header
request.URL = reqConfig.FullUrl // 请求接口
for pathParamName, pathParamValue := range reqConfig.PathParam {
if len(pathParamValue) == 0 {
continue
}
reqConfig.FullUrl = strings.ReplaceAll(reqConfig.FullUrl, "{"+pathParamName+"}", pathParamValue)
}
// 设置url参数, url path格式需要是 /user/{user_id}/detail格式, {user_id} 会自动替换
request.SetPathParams(reqConfig.PathParam)
request.Method = reqConfig.Method // 请求方法
cookieList := make([]*http.Cookie, 0)
for cookieName, cookieValue := range reqConfig.Cookie {
@ -81,7 +77,7 @@ func NewRestyClient(reqConfig *define.Request) (*resty.Client, *resty.Request) {
return client, request
}
// setRestyBody 设置请求BODY
// setRestyBody 设置请求BODY TODO: 支持xml / yml等
//
// Author : go_developer@163.com<白茶清欢>
//