From 9e22912ad2aae225861b66e5033a212801cfb07f Mon Sep 17 00:00:00 2001 From: nimrodishi <131989824+LegoTheGuideDog@users.noreply.github.com> Date: Wed, 10 Jan 2024 11:37:24 +0200 Subject: [PATCH] use a copy of the body in jsonBinding.Bind() --- binding/json.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/binding/json.go b/binding/json.go index e21c2ee3..cbc2c8da 100644 --- a/binding/json.go +++ b/binding/json.go @@ -34,7 +34,11 @@ func (jsonBinding) Bind(req *http.Request, obj any) error { if req == nil || req.Body == nil { return errors.New("invalid request") } - return decodeJSON(req.Body, obj) + body, err := req.GetBody() + if err != nil { + return err + } + return decodeJSON(body, obj) } func (jsonBinding) BindBody(body []byte, obj any) error {