修复完整URL拼接错误问题
This commit is contained in:
parent
b3ce41b3b0
commit
ede74d9508
6
rpc.go
6
rpc.go
@ -281,7 +281,7 @@ func (r *request) GetHttpClient(header map[string]string, timeout ApiTimeout) *h
|
|||||||
//
|
//
|
||||||
// Date : 17:23 2022/6/30
|
// Date : 17:23 2022/6/30
|
||||||
func (r *request) getFullURLAndBody(serviceConfig *Service, apiConfig *Api, parameter map[string]interface{}) (string, []byte) {
|
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 {
|
for name, val := range parameter {
|
||||||
fullURL = strings.ReplaceAll(fullURL, "{{"+name+"}}", fmt.Sprintf("%v", val))
|
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, "&")
|
query := strings.Join(parameterPair, "&")
|
||||||
if len(query) == 0 {
|
if len(query) == 0 {
|
||||||
return strings.ReplaceAll(fullURL, "//", "/"), body
|
return fullURL, body
|
||||||
}
|
}
|
||||||
return strings.ReplaceAll(fullURL, "//", "/") + "?" + query, body
|
return fullURL + "?" + query, body
|
||||||
}
|
}
|
||||||
|
|
||||||
// validateResponseHttpCode 验证http状态码
|
// validateResponseHttpCode 验证http状态码
|
||||||
|
Loading…
Reference in New Issue
Block a user