From ede74d9508d96314aa1b747895fd058518f0610e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 1 Jul 2022 16:23:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=8C=E6=95=B4URL?= =?UTF-8?q?=E6=8B=BC=E6=8E=A5=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rpc.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rpc.go b/rpc.go index c7de2c9..efd5e87 100644 --- a/rpc.go +++ b/rpc.go @@ -281,7 +281,7 @@ func (r *request) GetHttpClient(header map[string]string, timeout ApiTimeout) *h // // Date : 17:23 2022/6/30 func (r *request) getFullURLAndBody(serviceConfig *Service, apiConfig *Api, parameter map[string]interface{}) (string, []byte) { - fullURL := strings.ReplaceAll(serviceConfig.Domain+"/"+apiConfig.URI, "//", "/") + fullURL := strings.TrimRight(serviceConfig.Domain, "/") + "/" + strings.TrimLeft(apiConfig.URI, "/") for name, val := range parameter { fullURL = strings.ReplaceAll(fullURL, "{{"+name+"}}", fmt.Sprintf("%v", val)) } @@ -316,9 +316,9 @@ func (r *request) getFullURLAndBody(serviceConfig *Service, apiConfig *Api, para } query := strings.Join(parameterPair, "&") if len(query) == 0 { - return strings.ReplaceAll(fullURL, "//", "/"), body + return fullURL, body } - return strings.ReplaceAll(fullURL, "//", "/") + "?" + query, body + return fullURL + "?" + query, body } // validateResponseHttpCode 验证http状态码