From ab08aa9c9e6343a9eab8ddeb6b567b93128e3493 Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 25 Jul 2013 16:08:18 +0800 Subject: [PATCH] MethodByName --- router.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/router.go b/router.go index 8e8f3d91..e7409ecc 100644 --- a/router.go +++ b/router.go @@ -94,8 +94,8 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM } } } - reflectVal := reflect.Indirect(reflect.ValueOf(c)) - t := reflectVal.Type() + reflectVal := reflect.ValueOf(c) + t := reflect.Indirect(reflectVal).Type() methods := make(map[string]string) if len(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], ",") for _, m := range comma { 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] } else { panic(colon[1] + " method don't exist in the controller " + t.Name())