From 3504899a5d19777fbc0b1435d5a0ad61841ff61f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 11 Jun 2024 16:27:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AEpath=20para?= =?UTF-8?q?m=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resty.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/resty.go b/resty.go index 8330355..01e3043 100644 --- a/resty.go +++ b/resty.go @@ -39,7 +39,13 @@ func NewRestyClient(reqConfig *define.Request) (*resty.Client, *resty.Request) { request.SetQueryParams(reqConfig.Query) // 设置query参数 request.SetHeaders(reqConfig.Header) // 设置header request.URL = reqConfig.FullUrl // 请求接口 - request.Method = reqConfig.Method // 请求方法 + for pathParamName, pathParamValue := range reqConfig.PathParam { + if len(pathParamValue) == 0 { + continue + } + reqConfig.FullUrl = strings.ReplaceAll(reqConfig.FullUrl, "{#"+pathParamName+"#}", pathParamValue) + } + request.Method = reqConfig.Method // 请求方法 cookieList := make([]*http.Cookie, 0) for cookieName, cookieValue := range reqConfig.Cookie { cookieList = append(cookieList, &http.Cookie{