diff options
author | Wim <wim@42.be> | 2017-06-06 00:01:05 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-06-06 00:04:18 +0200 |
commit | 3a183cb218c6812964a70d2e75884ad7071d9c0c (patch) | |
tree | ee0d2492c27e84ace88acfcfdc533545f42ccb21 /vendor/github.com/labstack/echo/bind.go | |
parent | 2eecaccd1c77e8990a80e6b4b6ad6b13a9c95896 (diff) | |
download | matterbridge-msglm-3a183cb218c6812964a70d2e75884ad7071d9c0c.tar.gz matterbridge-msglm-3a183cb218c6812964a70d2e75884ad7071d9c0c.tar.bz2 matterbridge-msglm-3a183cb218c6812964a70d2e75884ad7071d9c0c.zip |
Update vendor
Diffstat (limited to 'vendor/github.com/labstack/echo/bind.go')
-rw-r--r-- | vendor/github.com/labstack/echo/bind.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/vendor/github.com/labstack/echo/bind.go b/vendor/github.com/labstack/echo/bind.go index f2393ea6..186bd83d 100644 --- a/vendor/github.com/labstack/echo/bind.go +++ b/vendor/github.com/labstack/echo/bind.go @@ -30,16 +30,16 @@ type ( // Bind implements the `Binder#Bind` function. func (b *DefaultBinder) Bind(i interface{}, c Context) (err error) { req := c.Request() - if req.Method == GET { - if err = b.bindData(i, c.QueryParams(), "query"); err != nil { - return NewHTTPError(http.StatusBadRequest, err.Error()) - } - return - } - ctype := req.Header.Get(HeaderContentType) if req.ContentLength == 0 { + if req.Method == GET || req.Method == DELETE { + if err = b.bindData(i, c.QueryParams(), "query"); err != nil { + return NewHTTPError(http.StatusBadRequest, err.Error()) + } + return + } return NewHTTPError(http.StatusBadRequest, "Request body can't be empty") } + ctype := req.Header.Get(HeaderContentType) switch { case strings.HasPrefix(ctype, MIMEApplicationJSON): if err = json.NewDecoder(req.Body).Decode(i); err != nil { @@ -51,7 +51,7 @@ func (b *DefaultBinder) Bind(i interface{}, c Context) (err error) { return NewHTTPError(http.StatusBadRequest, err.Error()) } } - case strings.HasPrefix(ctype, MIMEApplicationXML): + case strings.HasPrefix(ctype, MIMEApplicationXML), strings.HasPrefix(ctype, MIMETextXML): if err = xml.NewDecoder(req.Body).Decode(i); err != nil { if ute, ok := err.(*xml.UnsupportedTypeError); ok { return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unsupported type error: type=%v, error=%v", ute.Type, ute.Error())) @@ -142,6 +142,8 @@ func setWithProperType(valueKind reflect.Kind, val string, structField reflect.V } switch valueKind { + case reflect.Ptr: + return setWithProperType(structField.Elem().Kind(), val, structField.Elem()) case reflect.Int: return setIntField(val, 0, structField) case reflect.Int8: |