Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync v2.3 #1232

Merged
merged 5 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/internal/handler/route_online_debug/route_online_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 1 addition & 4 deletions api/test/e2e/route_online_debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading