mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-22 17:42:14 +08:00
add checkers for a types to match with the setter interface
This commit is contained in:
parent
cdc534f722
commit
adff101d26
@ -66,6 +66,8 @@ func (formMultipartBinding) Bind(req *http.Request, obj interface{}) error {
|
|||||||
|
|
||||||
type multipartRequest http.Request
|
type multipartRequest http.Request
|
||||||
|
|
||||||
|
var _ setter = (*multipartRequest)(nil)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
multipartFileHeaderStructType = reflect.TypeOf(multipart.FileHeader{})
|
multipartFileHeaderStructType = reflect.TypeOf(multipart.FileHeader{})
|
||||||
)
|
)
|
||||||
|
@ -31,12 +31,15 @@ func mapFormByTag(ptr interface{}, form map[string][]string, tag string) error {
|
|||||||
return mappingByPtr(ptr, formSource(form), tag)
|
return mappingByPtr(ptr, formSource(form), tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setter - try to set value on a walking by fields of a struct
|
||||||
type setter interface {
|
type setter interface {
|
||||||
Set(value reflect.Value, field reflect.StructField, key string, opt setOptions) (isSetted bool, err error)
|
Set(value reflect.Value, field reflect.StructField, key string, opt setOptions) (isSetted bool, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type formSource map[string][]string
|
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) {
|
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)
|
return setByForm(value, field, form, tagValue, opt)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user