...
|
...
|
@@ -35,17 +35,18 @@ func CreateResponseLogFilter(logger *logs.BeeLogger) func(ctx *context.Context) |
|
|
|
|
|
func CreateRequestBodyFilter() func(ctx *context.Context) {
|
|
|
return func(ctx *context.Context) {
|
|
|
if len(ctx.Input.RequestBody) == 0 {
|
|
|
if ctx.Request.Method == http.MethodPost || ctx.Request.Method == http.MethodPut {
|
|
|
body, _ := ioutil.ReadAll(ctx.Request.Body)
|
|
|
if len(body) == 0 {
|
|
|
body = []byte("{}")
|
|
|
}
|
|
|
ctx.Input.SetData("requestBody", body)
|
|
|
ctx.Request.Body.Close()
|
|
|
if ctx.Request.Method == http.MethodPost || ctx.Request.Method == http.MethodPut {
|
|
|
body, _ := ioutil.ReadAll(ctx.Request.Body)
|
|
|
if len(body) == 0 {
|
|
|
body = []byte("{}")
|
|
|
}
|
|
|
} else {
|
|
|
ctx.Input.SetData("requestBody", ctx.Input.RequestBody)
|
|
|
ctx.Input.SetData("requestBody", body)
|
|
|
ctx.Request.Body.Close()
|
|
|
}
|
|
|
//if len(ctx.Input.RequestBody) == 0 {
|
|
|
//
|
|
|
//} else {
|
|
|
// ctx.Input.SetData("requestBody", ctx.Input.RequestBody)
|
|
|
//}
|
|
|
}
|
|
|
} |
...
|
...
|
|