add checkers for a types to match with the setter interface

This commit is contained in:
Dmitry Kutakov 2019-03-30 16:59:42 +03:00
parent cdc534f722
commit adff101d26
2 changed files with 5 additions and 0 deletions

View File

@ -66,6 +66,8 @@ func (formMultipartBinding) Bind(req *http.Request, obj interface{}) error {
type multipartRequest http.Request
var _ setter = (*multipartRequest)(nil)
var (
multipartFileHeaderStructType = reflect.TypeOf(multipart.FileHeader{})
)

View File

@ -31,12 +31,15 @@ func mapFormByTag(ptr interface{}, form map[string][]string, tag string) error {
return mappingByPtr(ptr, formSource(form), tag)
}
// setter - try to set value on a walking by fields of a struct
type setter interface {
Set(value reflect.Value, field reflect.StructField, key string, opt setOptions) (isSetted bool, err error)
}
type formSource map[string][]string
var _ setter = formSource(nil)
func (form formSource) Set(value reflect.Value, field reflect.StructField, tagValue string, opt setOptions) (isSetted bool, err error) {
return setByForm(value, field, form, tagValue, opt)
}