From bd615fc96e791ec547c9e45fec9268bd25c1c55b Mon Sep 17 00:00:00 2001 From: Benoit Masson Date: Tue, 19 May 2020 12:36:48 +0200 Subject: [PATCH] Fix: allow bound interface to be a slice of data 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 #1356, #1448, #1495 (second case), #1565 --- bind.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bind.go b/bind.go index f89147435..9d17f0518 100644 --- a/bind.go +++ b/bind.go @@ -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") }