type Controller struct {
// context data
Ctx *context.Context //
Data map[interface{}]interface{}
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
XSRFExpire int
EnableXSRF bool
// session
CruSession session.Store
// contains filtered or unexported fields
}
接口
type ControllerInterface interface {
Init(ct *context.Context, controllerName, actionName string, app interface{})
Prepare() //函数执行之前执行,可以做一些检查,比如说权限
Get()
Post()
Delete()
Put()
Head()
Patch()
Options()
Trace()
Finish() //记录一些日志类动作
Render() error
XSRFToken() string
CheckXSRFCookie() bool
HandlerFunc(fn string) bool
URLMapping()
}
方法
type Controller
func (c *Controller) Abort(code string)
func (c *Controller) CheckXSRFCookie() bool
func (c *Controller) CustomAbort(status int, body string)
func (c *Controller) DelSession(name interface{})
func (c *Controller) Delete()
func (c *Controller) DestroySession()
func (c *Controller) Finish()
func (c *Controller) Get()
func (c *Controller) GetBool(key string, def ...bool) (bool, error)
func (c *Controller) GetControllerAndAction() (string, string)
func (c *Controller) GetFile(key string) (multipart.File, *multipart.FileHeader, error)
func (c *Controller) GetFiles(key string) ([]*multipart.FileHeader, error)
func (c *Controller) GetFloat(key string, def ...float64) (float64, error)
func (c *Controller) GetInt(key string, def ...int) (int, error)
func (c *Controller) GetInt16(key string, def ...int16) (int16, error)
func (c *Controller) GetInt32(key string, def ...int32) (int32, error)
func (c *Controller) GetInt64(key string, def ...int64) (int64, error)
func (c *Controller) GetInt8(key string, def ...int8) (int8, error)
func (c *Controller) GetSecureCookie(Secret, key string) (string, bool)
func (c *Controller) GetSession(name interface{}) interface{}
func (c *Controller) GetString(key string, def ...string) string
func (c *Controller) GetStrings(key string, def ...[]string) []string
func (c *Controller) GetUint16(key string, def ...uint16) (uint16, error)
func (c *Controller) GetUint32(key string, def ...uint32) (uint32, error)
func (c *Controller) GetUint64(key string, def ...uint64) (uint64, error)
func (c *Controller) GetUint8(key string, def ...uint8) (uint8, error)
func (c *Controller) HandlerFunc(fnname string) bool
func (c *Controller) Head()
func (c *Controller) Init(ctx *context.Context, controllerName, actionName string, app interface{})
func (c *Controller) Input() url.Values
func (c *Controller) IsAjax() bool
func (c *Controller) Mapping(method string, fn func())
func (c *Controller) Options()
func (c *Controller) ParseForm(obj interface{}) error
func (c *Controller) Patch()
func (c *Controller) Post()
func (c *Controller) Prepare()
func (c *Controller) Put()
func (c *Controller) Redirect(url string, code int)
func (c *Controller) Render() error
func (c *Controller) RenderBytes() ([]byte, error)
func (c *Controller) RenderString() (string, error)
func (c *Controller) SaveToFile(fromfile, tofile string) error
func (c *Controller) ServeFormatted(encoding ...bool)
func (c *Controller) ServeJSON(encoding ...bool)
func (c *Controller) ServeJSONP()
func (c *Controller) ServeXML()
func (c *Controller) ServeYAML()
func (c *Controller) SessionRegenerateID()
func (c *Controller) SetData(data interface{})
func (c *Controller) SetSecureCookie(Secret, name, value string, others ...interface{})
func (c *Controller) SetSession(name interface{}, value interface{})
func (c *Controller) StartSession() session.Store
func (c *Controller) StopRun()
func (c *Controller) Trace()
func (c *Controller) URLFor(endpoint string, values ...interface{}) string
func (c *Controller) URLMapping()
func (c *Controller) XSRFFormHTML() string func (c *Controller) XSRFToken() string
文档更新时间: 2023-07-11 17:20 作者:张尚