mirror of
https://github.com/astaxie/beego.git
synced 2025-07-04 10:00:18 +00:00
Fixed 2456 and strengthen bind
This commit is contained in:
@ -413,7 +413,13 @@ func (input *BeegoInput) Bind(dest interface{}, key string) error {
|
||||
if !value.CanSet() {
|
||||
return errors.New("beego: non-settable variable passed to Bind: " + key)
|
||||
}
|
||||
rv := input.bind(key, value.Type())
|
||||
typ := value.Type()
|
||||
// Get real type if dest define with interface{}.
|
||||
// e.g var dest interface{} dest=1.0
|
||||
if value.Kind() == reflect.Interface {
|
||||
typ = value.Elem().Type()
|
||||
}
|
||||
rv := input.bind(key, typ)
|
||||
if !rv.IsValid() {
|
||||
return errors.New("beego: reflect value is empty")
|
||||
}
|
||||
@ -422,6 +428,9 @@ func (input *BeegoInput) Bind(dest interface{}, key string) error {
|
||||
}
|
||||
|
||||
func (input *BeegoInput) bind(key string, typ reflect.Type) reflect.Value {
|
||||
if input.Context.Request.Form == nil {
|
||||
input.Context.Request.ParseForm()
|
||||
}
|
||||
rv := reflect.Zero(typ)
|
||||
switch typ.Kind() {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
|
Reference in New Issue
Block a user