mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 21:10:55 +00:00
MethodByName
This commit is contained in:
parent
7c610ee7c9
commit
ab08aa9c9e
@ -94,8 +94,8 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reflectVal := reflect.Indirect(reflect.ValueOf(c))
|
reflectVal := reflect.ValueOf(c)
|
||||||
t := reflectVal.Type()
|
t := reflect.Indirect(reflectVal).Type()
|
||||||
methods := make(map[string]string)
|
methods := make(map[string]string)
|
||||||
if len(mappingMethods) > 0 {
|
if len(mappingMethods) > 0 {
|
||||||
semi := strings.Split(mappingMethods[0], ";")
|
semi := strings.Split(mappingMethods[0], ";")
|
||||||
@ -107,7 +107,7 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM
|
|||||||
comma := strings.Split(colon[0], ",")
|
comma := strings.Split(colon[0], ",")
|
||||||
for _, m := range comma {
|
for _, m := range comma {
|
||||||
if m == "*" || inSlice(strings.ToLower(m), HTTPMETHOD) {
|
if m == "*" || inSlice(strings.ToLower(m), HTTPMETHOD) {
|
||||||
if val := reflectVal.FieldByName(colon[1]); val.IsValid() {
|
if val := reflectVal.MethodByName(colon[1]); val.IsValid() {
|
||||||
methods[strings.ToLower(m)] = colon[1]
|
methods[strings.ToLower(m)] = colon[1]
|
||||||
} else {
|
} else {
|
||||||
panic(colon[1] + " method don't exist in the controller " + t.Name())
|
panic(colon[1] + " method don't exist in the controller " + t.Name())
|
||||||
|
Loading…
Reference in New Issue
Block a user