Browse Source

fix url追加问题

pull/2/head
lucas 2 months ago
parent
commit
507dc26e61
  1. 4
      consumers/consumerHTTP_PRPXY.go
  2. 4
      dbHelper/httpHelper.go

4
consumers/consumerHTTP_PRPXY.go

@ -89,8 +89,8 @@ func (the *consumerHttpProxy) onData(w http.ResponseWriter, r *http.Request) {
"id": id,
}
//沿用请求路由
the.outHttpPost.Url += r.URL.String()
resp, err := the.outHttpPost.HttpPostWithParams(string(body), params)
newUrl := the.outHttpPost.Url + r.URL.String()
resp, err := the.outHttpPost.HttpPostWithParams(newUrl, string(body), params)
if err != nil {
return
}

4
dbHelper/httpHelper.go

@ -93,7 +93,7 @@ func (the *HttpHelper) PublishWithHeader(messageBytes []byte, headers map[string
}
return resp, err
}
func (the *HttpHelper) HttpPostWithParams(queryBody string, params map[string]string) (string, error) {
func (the *HttpHelper) HttpPostWithParams(urlStr, queryBody string, params map[string]string) (string, error) {
tr := &http.Transport{
DisableKeepAlives: true,
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
@ -103,7 +103,7 @@ func (the *HttpHelper) HttpPostWithParams(queryBody string, params map[string]st
for k, v := range params {
UrlParams.Set(k, v)
}
targetUrl, _ := url.ParseRequestURI(the.Url)
targetUrl, _ := url.ParseRequestURI(urlStr)
targetUrl.RawQuery = UrlParams.Encode()
req, err := http.NewRequest("POST", targetUrl.String(), strings.NewReader(queryBody))

Loading…
Cancel
Save