1
0
mirror of https://github.com/astaxie/beego.git synced 2024-06-26 18:34:13 +00:00

use reflect to ensure all methods been except

This commit is contained in:
JessonChan 2015-09-18 18:18:12 +08:00
parent 0ac690d2c8
commit 40cb8e0cf1

View File

@ -63,13 +63,14 @@ var (
"CONNECT": "CONNECT", "CONNECT": "CONNECT",
} }
// these beego.Controller's methods shouldn't reflect to AutoRouter // these beego.Controller's methods shouldn't reflect to AutoRouter
exceptMethod = []string{"Init", "Prepare", "Finish", "Render", "RenderString", exceptMethod = func() []string {
"RenderBytes", "Redirect", "Abort", "StopRun", "UrlFor", "ServeJson", "ServeJsonp", methods := []string{}
"ServeXml", "Input", "ParseForm", "GetString", "GetStrings", "GetInt", "GetBool", rv := reflect.TypeOf(&Controller{})
"GetFloat", "GetFile", "SaveToFile", "StartSession", "SetSession", "GetSession", for i := 0; i < rv.NumMethod(); i++ {
"DelSession", "SessionRegenerateID", "DestroySession", "IsAjax", "GetSecureCookie", methods = append(methods, rv.Method(i).Name)
"SetSecureCookie", "XsrfToken", "CheckXsrfCookie", "XsrfFormHtml", }
"GetControllerAndAction"} return methods
}()
urlPlaceholder = "{{placeholder}}" urlPlaceholder = "{{placeholder}}"
// DefaultAccessLogFilter will skip the accesslog if return true // DefaultAccessLogFilter will skip the accesslog if return true