mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 20:22:20 +08:00
Merge af0276fe98b2fe4aebf1a13fb9110fd82f26c7e6 into f05f966a0824b1d302ee556183e2579c91954266
This commit is contained in:
commit
591a7d8fa7
@ -5,6 +5,7 @@
|
|||||||
package gin
|
package gin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
@ -926,6 +927,10 @@ func (c *Context) ShouldBindBodyWith(obj any, bb binding.BindingBody) (err error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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)
|
c.Set(BodyBytesKey, body)
|
||||||
}
|
}
|
||||||
return bb.BindBody(body, obj)
|
return bb.BindBody(body, obj)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user