feat: ShouldBindWith support for reading saved body bytes

This commit is contained in:
myml 2018-12-11 10:16:47 +08:00
parent cce49582d6
commit 39a07fea9e

View File

@ -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)
}