camPluginRouter

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

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) Init

func (ctrl *Controller) Init()

OVERWRITE:

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

func (*ControllerAction) Call

func (action *ControllerAction) Call()

call action. only call once

func (*ControllerAction) Route

func (action *ControllerAction) Route() string

action route

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) Init

func (config *RouterPluginConfig) Init()

init

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL