4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-07-06 22:24:06 +00:00

Update dependencies (#975)

This commit is contained in:
Wim
2020-01-09 21:02:56 +01:00
committed by GitHub
parent b9354de8fd
commit 0f708daf2d
360 changed files with 72921 additions and 42691 deletions

View File

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