type Controller

## type Controller ```go type Controller struct { // context data Ctx *context.Context Data map[interface{}]interface{} // route controller info controllerName string actionName string methodMapping map[string]func() //method:routertree AppController interface{} // template data TplName string ViewPath string Layout string LayoutSections map[string]string // the key is the section name and the value is the template name TplPrefix string TplExt string EnableRender bool // xsrf data _xsrfToken string XSRFExpire int EnableXSRF bool // session CruSession session.Store } ``` - Ctx - Data ## Get() 作用 ```go 某个路由的 get 方法 // Get adds a request function to handle GET request. func (c *Controller) Get() { http.Error(c.Ctx.ResponseWriter, "Method Not Allowed", http.StatusMethodNotAllowed) } ``` ## Post() 作用 ```go 某个路由的 post 方法 // Get adds a request function to handle GET request. func (c *Controller) Get() { http.Error(c.Ctx.ResponseWriter, "Method Not Allowed", http.StatusMethodNotAllowed) } ``` ## Init(ctx *context.Context, controllerName, actionName string, app interface{}) 作用 ```go 设置 *Controller 的基础属性 // Init generates default values of controller operations. func (c *Controller) Init(ctx *context.Context, controllerName, actionName string, app interface{}) { c.Layout = "" c.TplName = "" c.controllerName = controllerName c.actionName = actionName c.Ctx = ctx c.TplExt = "tpl" c.AppController = app c.EnableRender = true c.EnableXSRF = true c.Data = ctx.Input.Data() c.methodMapping = make(map[string]func()) } ```