camRouter

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: Apache-2.0 Imports: 5 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 {
	camStatics.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 camStatics.ControllerActionInterface, response []byte) []byte

OVERWRITE

func (*Controller) BeforeAction

func (ctrl *Controller) BeforeAction(action camStatics.ControllerActionInterface) bool

OVERWRITE

func (*Controller) GetContext

func (ctrl *Controller) GetContext() camStatics.ContextInterface

OVERWRITE

func (*Controller) GetDefaultActionName

func (ctrl *Controller) GetDefaultActionName() string

OVERWRITE

func (*Controller) GetRecover

func (ctrl *Controller) GetRecover() camStatics.RecoverInterface

get recover

func (*Controller) GetString added in v0.5.0

func (ctrl *Controller) GetString(key string) string

get the value with string type

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 camStatics.ContextInterface)

OVERWRITE

func (*Controller) SetRecover

func (ctrl *Controller) SetRecover(rec camStatics.RecoverInterface)

set recover Deprecated

func (*Controller) SetValues

func (ctrl *Controller) SetValues(values map[string]interface{})

OVERWRITE set values

type ControllerAction

type ControllerAction struct {
	camStatics.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 RouterOption added in v0.5.0

type RouterOption struct {
	// Default route
	DefaultRoute string
	// Recover route
	RecoverRoute string
	// Receive message parse handler
	RecvMessageParseHandler plugin.RecvMessageParseHandler
	// Send message parse handler
	SendMessageParseHandler plugin.SendMessageParseHandler
}

public options

type RouterPlugin

type RouterPlugin struct {
	camStatics.PluginInterface
	// contains filtered or unexported fields
}

func (*RouterPlugin) GetControllerAction

func (plugin *RouterPlugin) GetControllerAction(route string) (controller camStatics.ControllerInterface, action camStatics.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) GetCustomHandler

func (plugin *RouterPlugin) GetCustomHandler(route string) camStatics.RouteHandler

Get custom route

func (*RouterPlugin) GetRecoverControllerAction

func (plugin *RouterPlugin) GetRecoverControllerAction() (controller camStatics.ControllerInterface, action camStatics.ControllerActionInterface)

Get recover controller and action

func (*RouterPlugin) GetRecoverRoute

func (plugin *RouterPlugin) GetRecoverRoute() string

GetRecover router

func (*RouterPlugin) Init

func (plugin *RouterPlugin) Init(config *RouterPluginConfig)

type RouterPluginConfig

type RouterPluginConfig struct {
	camStatics.PluginConfigInterface
	// contains filtered or unexported fields
}

router plugin. it can inject component if it need to

func (*RouterPluginConfig) AddRoute

func (conf *RouterPluginConfig) AddRoute(route string, handler camStatics.RouteHandler)

add router handler. its priority is higher than the controller.

func (*RouterPluginConfig) DefaultRoute added in v0.5.0

func (conf *RouterPluginConfig) DefaultRoute() string

Get default route

func (*RouterPluginConfig) GetRecvMessageParseHandler added in v0.4.3

func (conf *RouterPluginConfig) GetRecvMessageParseHandler() plugin.RecvMessageParseHandler

func (*RouterPluginConfig) GetSendMessageParseHandler added in v0.5.2

func (conf *RouterPluginConfig) GetSendMessageParseHandler() plugin.SendMessageParseHandler

func (*RouterPluginConfig) Init

func (conf *RouterPluginConfig) Init()

init

func (*RouterPluginConfig) RecoverRoute deprecated

func (conf *RouterPluginConfig) RecoverRoute(route string)

Deprecated: remove since v0.6.0. instead by RouterOption() recover route. when panic on controller, Is will catch error and redirect to this route

func (*RouterPluginConfig) Register

func (conf *RouterPluginConfig) Register(controller camStatics.ControllerInterface)

register controller controller: Inout &Controller{} OR new(Controller) OR Controller{} is ok

func (*RouterPluginConfig) RouterOption added in v0.5.0

func (conf *RouterPluginConfig) RouterOption(opt *RouterOption)

Set router option

func (*RouterPluginConfig) SetRecvMessageParseHandler deprecated added in v0.4.3

func (conf *RouterPluginConfig) SetRecvMessageParseHandler(handler plugin.RecvMessageParseHandler)

Deprecated: remove since v0.6.0. instead by RouterOption()

func (*RouterPluginConfig) SetSendMessageParseHandler added in v0.5.2

func (conf *RouterPluginConfig) SetSendMessageParseHandler(handler plugin.SendMessageParseHandler)

Jump to

Keyboard shortcuts

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