Skip to content

Commit

Permalink
Fix: allow bound interface to be a slice of data
Browse files Browse the repository at this point in the history
Do not throw an error when binding to a slice, if binding occurs
on path- or query-parameters
=> data is very likely to be found in the body, which will be bound later

Should fix labstack#1356, labstack#1448, labstack#1495 (second case), labstack#1565
  • Loading branch information
benoitmasson committed May 19, 2020
1 parent d2e3004 commit 5256b3b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ func (b *DefaultBinder) bindData(ptr interface{}, data map[string][]string, tag

// !struct
if typ.Kind() != reflect.Struct {
if tag == "param" || tag == "query" {
// incompatible type, data is probably to be found in the body
return nil
}
return errors.New("binding element must be a struct")
}

Expand Down

0 comments on commit 5256b3b

Please sign in to comment.