This is an automated email from the ASF dual-hosted git repository.

juzhiyuan pushed a commit to branch v2.3-sync
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git

commit 4e4332dd57a743fb8d151fbb0cdc343dea7f642a
Author: liuxiran <belovedx...@126.com>
AuthorDate: Wed Jan 6 10:38:56 2021 +0800

    fix(be): change bodyParams to string to accept any content-type (#1202)
    
    * fix: change bodyParams to string to accept any content-type
    
    * fix: ci error
    
    * fix: change bodyparam to type string in e2e test case
    
    * fix: ci
    
    Co-authored-by: 琚致远 <juzhiy...@apache.org>
---
 api/internal/handler/route_online_debug/route_online_debug.go | 6 +++---
 api/test/e2e/route_online_debug_test.go                       | 5 +----
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/api/internal/handler/route_online_debug/route_online_debug.go 
b/api/internal/handler/route_online_debug/route_online_debug.go
index 18241b7..ac1c502 100644
--- a/api/internal/handler/route_online_debug/route_online_debug.go
+++ b/api/internal/handler/route_online_debug/route_online_debug.go
@@ -52,7 +52,7 @@ func (h *Handler) ApplyRoute(r *gin.Engine) {
 type ParamsInput struct {
        URL             string              `json:"url,omitempty"`
        RequestProtocol string              `json:"request_protocol,omitempty"`
-       BodyParams      map[string]string   `json:"body_params,omitempty"`
+       BodyParams      string              `json:"body_params,omitempty"`
        Method          string              `json:"method,omitempty"`
        HeaderParams    map[string][]string `json:"header_params,omitempty"`
 }
@@ -88,11 +88,11 @@ type HTTPProtocolSupport struct {
 
 func (h *HTTPProtocolSupport) RequestForwarding(c droplet.Context) 
(interface{}, error) {
        paramsInput := c.Input().(*ParamsInput)
-       bodyParams, _ := json.Marshal(paramsInput.BodyParams)
+       bodyParams := paramsInput.BodyParams
        client := &http.Client{}
 
        client.Timeout = 5 * time.Second
-       req, err := http.NewRequest(strings.ToUpper(paramsInput.Method), 
paramsInput.URL, strings.NewReader(string(bodyParams)))
+       req, err := http.NewRequest(strings.ToUpper(paramsInput.Method), 
paramsInput.URL, strings.NewReader(bodyParams))
        if err != nil {
                return &data.SpecCodeResponse{StatusCode: 
http.StatusInternalServerError}, err
        }
diff --git a/api/test/e2e/route_online_debug_test.go 
b/api/test/e2e/route_online_debug_test.go
index 4796d20..fba4f03 100644
--- a/api/test/e2e/route_online_debug_test.go
+++ b/api/test/e2e/route_online_debug_test.go
@@ -242,10 +242,7 @@ func TestRoute_Online_Debug_Route_With_Body_Params(t 
*testing.T) {
                                "url": "` + APISIXInternalUrl + `/hello",
                                "request_protocol": "http",
                                "method": "POST",
-                               "body_params": {
-                                       "name": "test",
-                                       "desc": "online debug route with body 
params"
-                               }
+                               "body_params": 
"{\"name\":\"test\",\"desc\":\"online debug route with body params\"}"
                        }`,
                        Headers:      map[string]string{"Authorization": token},
                        ExpectStatus: http.StatusOK,

Reply via email to