Documentation
¶
Index ¶
- func GetRouteNameContext(ctx context.Context) string
- func SetRouteNameContext(ctx context.Context, route string) context.Context
- type Handler
- type Middleware
- type Route
- type Router
- func (r *Router) GetAllRoutes() []*Route
- func (r *Router) GetIDLastRoute() uint16
- func (r *Router) Handle(name string, h Handler) int
- func (r *Router) HandleWith(mw Middleware, route string, h Handler) int
- func (r *Router) Mount(prefix string, subRouter *Router)
- func (r *Router) Process(ctx context.Context, data []byte) ([]byte, error)
- func (r *Router) ReplaceGetRoutes(h Handler)
- func (r *Router) Use(mw Middleware)
- func (r *Router) UseWithGetRoutes(mw Middleware)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRouteNameContext ¶
GetRouteNameContext returns route name from context
Types ¶
type Middleware ¶
Middleware is the called function before the handler every time
type Route ¶
type Route struct { Name string // contains filtered or unexported fields }
Route is contains registered name
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router allows to registers Handlers and call them
func (*Router) GetAllRoutes ¶
GetAllRoutes allows you get raw list of the routes
func (*Router) GetIDLastRoute ¶
GetIDLastRoute returns id of the last route in routes list
func (*Router) HandleWith ¶
func (r *Router) HandleWith(mw Middleware, route string, h Handler) int
HandleWith registers handle with single middleware
func (*Router) Mount ¶
Mount append routes and middlewares of the subRouter into main router Routes of the subRouter will wrapped middlewares of the main router Prefix can be empty ""
func (*Router) ReplaceGetRoutes ¶
ReplaceGetRoutes allows you to set your own route list view Use GetAllRoutes to get raw list of the routes
func (*Router) Use ¶
func (r *Router) Use(mw Middleware)
Use applies middleware to Handlers added later
func (*Router) UseWithGetRoutes ¶
func (r *Router) UseWithGetRoutes(mw Middleware)
UseWithGetRoutes applies middleware only to Handlers and to _getRoutes If you don't want to apply to the _getRoutes use: just "Use"