diff --git a/gateway/mw_url_rewrite.go b/gateway/mw_url_rewrite.go index b34b10be690..1966c0bcc9e 100644 --- a/gateway/mw_url_rewrite.go +++ b/gateway/mw_url_rewrite.go @@ -1,6 +1,7 @@ package gateway import ( + "bytes" "fmt" "io" "net/http" @@ -704,6 +705,7 @@ func checkPayload(r *http.Request, options apidef.StringRegexMap, triggernum int log.WithError(err).Error("error reading request body") return false } + r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes)) // Perform regex matching on the request body matched, matches := options.FindAllStringSubmatch(string(bodyBytes), -1) diff --git a/gateway/mw_validate_json.go b/gateway/mw_validate_json.go index efcd50d034d..48773e79634 100644 --- a/gateway/mw_validate_json.go +++ b/gateway/mw_validate_json.go @@ -1,6 +1,7 @@ package gateway import ( + "bytes" "errors" "fmt" "io" @@ -54,6 +55,7 @@ func (k *ValidateJSON) ProcessRequest(w http.ResponseWriter, r *http.Request, _ if err != nil { return err, http.StatusBadRequest } + r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes)) defer r.Body.Close() inputLoader := gojsonschema.NewBytesLoader(bodyBytes)