1
0
mirror of https://github.com/astaxie/beego.git synced 2024-06-18 12:14:15 +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",
}
// these beego.Controller's methods shouldn't reflect to AutoRouter
exceptMethod = []string{"Init", "Prepare", "Finish", "Render", "RenderString",
"RenderBytes", "Redirect", "Abort", "StopRun", "UrlFor", "ServeJson", "ServeJsonp",
"ServeXml", "Input", "ParseForm", "GetString", "GetStrings", "GetInt", "GetBool",
"GetFloat", "GetFile", "SaveToFile", "StartSession", "SetSession", "GetSession",
"DelSession", "SessionRegenerateID", "DestroySession", "IsAjax", "GetSecureCookie",
"SetSecureCookie", "XsrfToken", "CheckXsrfCookie", "XsrfFormHtml",
"GetControllerAndAction"}
exceptMethod = func() []string {
methods := []string{}
rv := reflect.TypeOf(&Controller{})
for i := 0; i < rv.NumMethod(); i++ {
methods = append(methods, rv.Method(i).Name)
}
return methods
}()
urlPlaceholder = "{{placeholder}}"
// DefaultAccessLogFilter will skip the accesslog if return true