Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMissingControllerInstance is a static error which fired from `Controller` when // the passed "c" instnace is not a valid type of `Controller`. ErrMissingControllerInstance = errors.New("controller should have a field of Controller type") // ErrInvalidControllerType fired when the "Controller" field is not // the correct type. ErrInvalidControllerType = errors.New("controller instance is not a valid implementation") )
Functions ¶
func Register ¶
func Register(controller BaseController, bindValues []interface{}, registerFunc RegisterFunc) error
Register receives a "controller", a pointer of an instance which embeds the `Controller`, the value of "baseControllerFieldName" should be `Controller`.
func RegisterMethodHandlers ¶
func RegisterMethodHandlers(t TController, registerFunc RegisterFunc)
RegisterMethodHandlers receives a `TController`, description of the user's controller, and calls the "registerFunc" for each of its method handlers.
Not useful for the end-developer, but may needed for debugging at the future.
Types ¶
type BaseController ¶
type BaseController interface {
SetName(name string)
BeginRequest(ctx context.Context)
EndRequest(ctx context.Context)
}
BaseController is the controller interface, which the main request `Controller` will implement automatically. End-User doesn't need to have any knowledge of this if she/he doesn't want to implement a new Controller type.
type RegisterFunc ¶
RegisterFunc used by the caller to register the result routes.
type TController ¶
type TController struct {
// The name of the front controller struct.
Name string
// FullName it's the last package path segment + "." + the Name.
// i.e: if login-example/user/controller.go, the FullName is "user.Controller".
FullName string
// the type of the user/dev's "c" controller (interface{}).
Type reflect.Type
// it's the first passed value of the controller instance,
// we need this to collect and save the persistence fields' values.
Value reflect.Value
// contains filtered or unexported fields
}
TController is the type of the controller, it contains all the necessary information to load and serve the controller to the outside world, think it as a "supervisor" of your Controller which cares about you.
func ActivateController ¶
func ActivateController(base BaseController, bindValues []interface{}) (TController, error)
ActivateController returns a new controller type info description.
func (TController) HandlerOf ¶
func (t TController) HandlerOf(methodFunc methodfunc.MethodFunc) context.Handler
HandlerOf builds the handler for a type based on the specific method func.