diff options
author | Wim <wim@42.be> | 2020-01-09 21:02:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-09 21:02:56 +0100 |
commit | 0f708daf2d14dcca261ef98cc698a1b1f2a6aa74 (patch) | |
tree | 022eee21366d6a9a00feaeff918972d9e72632c2 /vendor/github.com/labstack/echo/v4/bind.go | |
parent | b9354de8fd5e424ac2f246fff1a03b27e8094fd8 (diff) | |
download | matterbridge-msglm-0f708daf2d14dcca261ef98cc698a1b1f2a6aa74.tar.gz matterbridge-msglm-0f708daf2d14dcca261ef98cc698a1b1f2a6aa74.tar.bz2 matterbridge-msglm-0f708daf2d14dcca261ef98cc698a1b1f2a6aa74.zip |
Update dependencies (#975)
Diffstat (limited to 'vendor/github.com/labstack/echo/v4/bind.go')
-rw-r--r-- | vendor/github.com/labstack/echo/v4/bind.go | 18 |
1 files changed, 8 insertions, 10 deletions
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") } |