Documentation ¶
Index ¶
- type Controller
- func (ctrl *Controller) AddValue(key string, value interface{})
- func (ctrl *Controller) AfterAction(action camBase.ControllerActionInterface, response []byte) []byte
- func (ctrl *Controller) BeforeAction(action camBase.ControllerActionInterface) bool
- func (ctrl *Controller) GetContext() camBase.ContextInterface
- func (ctrl *Controller) GetDefaultActionName() string
- func (ctrl *Controller) GetRecover() camBase.RecoverInterface
- func (ctrl *Controller) GetResponse() []byte
- func (ctrl *Controller) GetSession() camBase.SessionInterface
- func (ctrl *Controller) GetValue(key string) interface{}
- func (ctrl *Controller) GetValues() map[string]interface{}
- func (ctrl *Controller) Init()
- func (ctrl *Controller) SetContext(context camBase.ContextInterface)
- func (ctrl *Controller) SetRecover(rec camBase.RecoverInterface)
- func (ctrl *Controller) SetResponse(bytes []byte)
- func (ctrl *Controller) SetSession(session camBase.SessionInterface)
- func (ctrl *Controller) SetValues(values map[string]interface{})
- type ControllerAction
- type RouterPlugin
- func (plugin *RouterPlugin) GetControllerAction(route string) (controller camBase.ControllerInterface, ...)
- func (plugin *RouterPlugin) GetControllerActionName(route string) (controllerName string, actionName string)
- func (plugin *RouterPlugin) GetRecoverControllerAction() (controller camBase.ControllerInterface, ...)
- func (plugin *RouterPlugin) Init(config *RouterPluginConfig)
- type RouterPluginConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct { camBase.ControllerInterface // contains filtered or unexported fields }
base controller
func (*Controller) AddValue ¶
func (ctrl *Controller) AddValue(key string, value interface{})
OVERWRITE
func (*Controller) AfterAction ¶
func (ctrl *Controller) AfterAction(action camBase.ControllerActionInterface, response []byte) []byte
OVERWRITE
func (*Controller) BeforeAction ¶
func (ctrl *Controller) BeforeAction(action camBase.ControllerActionInterface) bool
OVERWRITE
func (*Controller) GetContext ¶
func (ctrl *Controller) GetContext() camBase.ContextInterface
OVERWRITE
func (*Controller) GetDefaultActionName ¶
func (ctrl *Controller) GetDefaultActionName() string
OVERWRITE
func (*Controller) GetRecover ¶
func (ctrl *Controller) GetRecover() camBase.RecoverInterface
get recover
func (*Controller) GetResponse ¶
func (ctrl *Controller) GetResponse() []byte
OVERWRITE return action write
func (*Controller) GetSession ¶
func (ctrl *Controller) GetSession() camBase.SessionInterface
OVERWRITE
func (*Controller) GetValue ¶
func (ctrl *Controller) GetValue(key string) interface{}
get value by key
func (*Controller) GetValues ¶
func (ctrl *Controller) GetValues() map[string]interface{}
get all values
func (*Controller) SetContext ¶
func (ctrl *Controller) SetContext(context camBase.ContextInterface)
OVERWRITE
func (*Controller) SetRecover ¶
func (ctrl *Controller) SetRecover(rec camBase.RecoverInterface)
set recover
func (*Controller) SetResponse ¶
func (ctrl *Controller) SetResponse(bytes []byte)
set response content
func (*Controller) SetSession ¶
func (ctrl *Controller) SetSession(session camBase.SessionInterface)
OVERWRITE
func (*Controller) SetValues ¶
func (ctrl *Controller) SetValues(values map[string]interface{})
OVERWRITE set values
type ControllerAction ¶
type ControllerAction struct { camBase.ControllerActionInterface // contains filtered or unexported fields }
controller action
func NewControllerAction ¶
func NewControllerAction(route string, rValue *reflect.Value) *ControllerAction
new action
type RouterPlugin ¶
type RouterPlugin struct { camBase.PluginInterface // contains filtered or unexported fields }
func (*RouterPlugin) GetControllerAction ¶
func (plugin *RouterPlugin) GetControllerAction(route string) (controller camBase.ControllerInterface, action camBase.ControllerActionInterface)
Get controller and action by route
route: controller and action name. Example: "user/register-and-login"
controller: the controller interface
return nil if controller not exists
action: the method, controller's action. You can call by `action.Call()` is ok
return nil if action not exists
controllerName: Example: "User" actionName: Example: "RegisterAndLogin"
func (*RouterPlugin) GetControllerActionName ¶
func (plugin *RouterPlugin) GetControllerActionName(route string) (controllerName string, actionName string)
get controllerName and actionName
func (*RouterPlugin) GetRecoverControllerAction ¶
func (plugin *RouterPlugin) GetRecoverControllerAction() (controller camBase.ControllerInterface, action camBase.ControllerActionInterface)
get recover controller and action
func (*RouterPlugin) Init ¶
func (plugin *RouterPlugin) Init(config *RouterPluginConfig)
type RouterPluginConfig ¶
type RouterPluginConfig struct { camBase.PluginConfigInterface // controller list ControllerList []camBase.ControllerInterface // contains filtered or unexported fields }
router plugin. it can inject component if it need to
func (*RouterPluginConfig) RecoverRoute ¶
func (config *RouterPluginConfig) RecoverRoute(route string)
recover route. when panic on controller, Is will catch error and redirect to this route
func (*RouterPluginConfig) Register ¶
func (config *RouterPluginConfig) Register(controller camBase.ControllerInterface)
register controller controller: Inout &Controller{} OR new(Controller) OR Controller{} is ok