修复完整URL拼接错误问题

This commit is contained in:
白茶清欢 2022-07-01 16:23:20 +08:00
parent b3ce41b3b0
commit ede74d9508

6
rpc.go
View File

@ -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状态码