mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-18 23:12:17 +08:00
Changed as requested
This commit is contained in:
parent
94e50b3e1f
commit
1fd4868074
@ -367,6 +367,7 @@ func head(str, sep string) (head string, tail string) {
|
|||||||
|
|
||||||
func setFormMap(ptr interface{}, form map[string][]string) error {
|
func setFormMap(ptr interface{}, form map[string][]string) error {
|
||||||
el := reflect.TypeOf(ptr).Elem()
|
el := reflect.TypeOf(ptr).Elem()
|
||||||
|
|
||||||
if el.Kind() == reflect.Slice {
|
if el.Kind() == reflect.Slice {
|
||||||
ptrMap, ok := ptr.(map[string][]string)
|
ptrMap, ok := ptr.(map[string][]string)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -375,7 +376,10 @@ func setFormMap(ptr interface{}, form map[string][]string) error {
|
|||||||
for k, v := range form {
|
for k, v := range form {
|
||||||
ptrMap[k] = v
|
ptrMap[k] = v
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
ptrMap, ok := ptr.(map[string]string)
|
ptrMap, ok := ptr.(map[string]string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("cannot convert to map of strings")
|
return errors.New("cannot convert to map of strings")
|
||||||
@ -383,6 +387,6 @@ func setFormMap(ptr interface{}, form map[string][]string) error {
|
|||||||
for k, v := range form {
|
for k, v := range form {
|
||||||
ptrMap[k] = v[len(v)-1] // pick last
|
ptrMap[k] = v[len(v)-1] // pick last
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user