Merge af0276fe98b2fe4aebf1a13fb9110fd82f26c7e6 into f05f966a0824b1d302ee556183e2579c91954266

This commit is contained in:
dilin 2024-09-22 07:57:24 +08:00 committed by GitHub
commit 591a7d8fa7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,6 +5,7 @@
package gin
import (
"bytes"
"errors"
"io"
"log"
@ -926,6 +927,10 @@ func (c *Context) ShouldBindBodyWith(obj any, bb binding.BindingBody) (err error
if err != nil {
return err
}
// close the body
c.Request.Body.Close()
// reset the body to the original unread state
c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(body))
c.Set(BodyBytesKey, body)
}
return bb.BindBody(body, obj)