mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-22 17:42:14 +08:00
feat: ShouldBindWith support for reading saved body bytes
This commit is contained in:
parent
cce49582d6
commit
39a07fea9e
@ -586,6 +586,13 @@ func (c *Context) ShouldBindUri(obj interface{}) error {
|
||||
// ShouldBindWith binds the passed struct pointer using the specified binding engine.
|
||||
// See the binding package.
|
||||
func (c *Context) ShouldBindWith(obj interface{}, b binding.Binding) error {
|
||||
if bb, ok := b.(binding.BindingBody); ok {
|
||||
if cb, ok := c.Get(BodyBytesKey); ok {
|
||||
if body, ok := cb.([]byte); ok {
|
||||
return bb.BindBody(body, obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
return b.Bind(c.Request, obj)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user