Documentation ¶
Index ¶
- func BindJSON(payload interface{}, v interface{}) (err error)
- func BindString(payload string, s *string) (err error)
- type BaseRequest
- type BaseRequestContext
- type Binder
- type Executer
- type Group
- func (g *Group) ADD(path string, generator HandlerGenerator) (err error)
- func (g *Group) AddGroup(path string, middleware ...Middleware) (newGroup *Group, err error)
- func (g *Group) BasePath() (path string)
- func (g *Group) DELETE(path string, generator HandlerGenerator) (err error)
- func (g *Group) GET(path string, generator HandlerGenerator) (err error)
- func (g *Group) GetGroups() (groups []*Group)
- func (g *Group) GetMiddleware() (middleware []Middleware)
- func (g *Group) GetRoutes() (routes map[Type]map[string]HandlerGenerator)
- func (g *Group) Handle(t Type, path string, generator HandlerGenerator) (err error)
- func (g *Group) HasGroup(path string) (exists bool)
- func (g *Group) HasRoute(t Type, path string) (exists bool)
- func (g *Group) Path() (path string)
- func (g *Group) UPDATE(path string, generator HandlerGenerator) (err error)
- type Grouper
- type Handler
- type HandlerGenerator
- type Middleware
- type Request
- type RequestContext
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindJSON ¶
func BindJSON(payload interface{}, v interface{}) (err error)
BindJSON data to a request handler
func BindString ¶
BindString data to a request handler
Types ¶
type BaseRequest ¶
type BaseRequest struct {
// contains filtered or unexported fields
}
BaseRequest embeddable
func (*BaseRequest) Context ¶
func (r *BaseRequest) Context() (ctx RequestContext)
Context get the context of the request
func (*BaseRequest) Initialize ¶
func (r *BaseRequest) Initialize(ctx RequestContext, tx *storage.Transaction)
Initialize the request
func (*BaseRequest) Token ¶
func (r *BaseRequest) Token() (token *string)
Token used for the request
func (*BaseRequest) Tx ¶
func (r *BaseRequest) Tx() (tx *storage.Transaction)
Tx get the transaction for the request
type BaseRequestContext ¶
type BaseRequestContext struct { service.Container Language *language.Tag // contains filtered or unexported fields }
BaseRequestContext of a connection
func NewRequestContext ¶
func NewRequestContext(c service.Container, language *language.Tag, token string) (r *BaseRequestContext)
NewRequestContext creates a new context instance
func (*BaseRequestContext) Token ¶
func (b *BaseRequestContext) Token() (token *string)
Token used in the context
type Executer ¶
type Executer interface {
Execute() (data interface{}, err error)
}
Executer for a request handler Returns data that is used as response (can also be nil)
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group of routes
func (*Group) ADD ¶
func (g *Group) ADD(path string, generator HandlerGenerator) (err error)
ADD handler
func (*Group) AddGroup ¶
func (g *Group) AddGroup(path string, middleware ...Middleware) (newGroup *Group, err error)
AddGroup create a group below the current group
func (*Group) DELETE ¶
func (g *Group) DELETE(path string, generator HandlerGenerator) (err error)
DELETE handler
func (*Group) GET ¶
func (g *Group) GET(path string, generator HandlerGenerator) (err error)
GET handler
func (*Group) GetMiddleware ¶
func (g *Group) GetMiddleware() (middleware []Middleware)
GetMiddleware returns the middleware handler of the group
func (*Group) GetRoutes ¶
func (g *Group) GetRoutes() (routes map[Type]map[string]HandlerGenerator)
GetRoutes returns the handler map grouped by type and path
func (*Group) Handle ¶
func (g *Group) Handle(t Type, path string, generator HandlerGenerator) (err error)
Handle a request (you can also use the aliases GET, UPDATE, ADD, DELETE)
type Grouper ¶
type Grouper interface { AddGroup(path string, middleware ...Middleware) (newGroup *Group, err error) HasRoute(t Type, path string) (exists bool) HasGroup(path string) (exists bool) GET(path string, generator HandlerGenerator) (err error) UPDATE(path string, generator HandlerGenerator) (err error) ADD(path string, generator HandlerGenerator) (err error) DELETE(path string, generator HandlerGenerator) (err error) Handle(t Type, path string, generator HandlerGenerator) (err error) BasePath() (path string) Path() (path string) GetMiddleware() (middleware []Middleware) GetGroups() (groups []*Group) GetRoutes() (routes map[Type]map[string]HandlerGenerator) }
Grouper group interface
type HandlerGenerator ¶
type HandlerGenerator func() Handler
HandlerGenerator instantiates a handler
type Middleware ¶
type Middleware interface {
Execute(ctx RequestContext) (cancel bool, err error)
}
Middleware for route groups
type Request ¶
type Request interface { Initialize(ctx RequestContext, tx *storage.Transaction) Context() (ctx RequestContext) Tx() (tx *storage.Transaction) Token() (token *string) }
Request to the websocket
type RequestContext ¶
RequestContext context functions for a request