From 0f708daf2d14dcca261ef98cc698a1b1f2a6aa74 Mon Sep 17 00:00:00 2001 From: Wim Date: Thu, 9 Jan 2020 21:02:56 +0100 Subject: Update dependencies (#975) --- vendor/github.com/labstack/echo/v4/bind.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'vendor/github.com/labstack/echo/v4/bind.go') diff --git a/vendor/github.com/labstack/echo/v4/bind.go b/vendor/github.com/labstack/echo/v4/bind.go index 959a314c..c8c88bb2 100644 --- a/vendor/github.com/labstack/echo/v4/bind.go +++ b/vendor/github.com/labstack/echo/v4/bind.go @@ -43,15 +43,11 @@ func (b *DefaultBinder) Bind(i interface{}, c Context) (err error) { if err := b.bindData(i, params, "param"); err != nil { return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err) } - + if err = b.bindData(i, c.QueryParams(), "query"); err != nil { + return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err) + } if req.ContentLength == 0 { - if req.Method == http.MethodGet || req.Method == http.MethodDelete { - if err = b.bindData(i, c.QueryParams(), "query"); err != nil { - return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err) - } - return - } - return NewHTTPError(http.StatusBadRequest, "Request body can't be empty") + return } ctype := req.Header.Get(HeaderContentType) switch { @@ -94,13 +90,15 @@ func (b *DefaultBinder) bindData(ptr interface{}, data map[string][]string, tag typ := reflect.TypeOf(ptr).Elem() val := reflect.ValueOf(ptr).Elem() - if m, ok := ptr.(*map[string]interface{}); ok { + // Map + if typ.Kind() == reflect.Map { for k, v := range data { - (*m)[k] = v[0] + val.SetMapIndex(reflect.ValueOf(k), reflect.ValueOf(v[0])) } return nil } + // !struct if typ.Kind() != reflect.Struct { return errors.New("binding element must be a struct") } -- cgit v1.2.3