From 39a07fea9ebfe5117d311e545d8da5a38f91646e Mon Sep 17 00:00:00 2001 From: myml Date: Tue, 11 Dec 2018 10:16:47 +0800 Subject: [PATCH] feat: ShouldBindWith support for reading saved body bytes --- context.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/context.go b/context.go index 478e8c09..a261efd9 100644 --- a/context.go +++ b/context.go @@ -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) }