Documentation ¶
Overview ¶
Package routing provides the name resolving utility for the fasthttp.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Middleware ¶
Middleware is a wrapping function that filters the request.
type NestedRouter ¶
type NestedRouter func() Router
NestedRouter is a generator function that returns the Router handler.
type Router ¶
type Router = fasthttp.RequestHandler
Router is an alias type of the fasthttp.RequestHandler.
func ApplyMiddlware ¶
func ApplyMiddlware(source Router, middlewares ...Middleware) (handler Router)
ApplyMiddlware is a function that applies the given middleware for the handler.
func JustCode ¶
func JustCode(statusHandler eighty.HandledError, middlewares ...Middleware) (handler Router)
JustCode is a simple handler function that just only returns the http status code.
type RouterContext ¶
type RouterContext interface { // UrlResolver returns a UrlResolver. UrlResolver() UrlResolver // UrlPrefix returns the URL prefix that is added across the entire routing group. UrlPrefix() string // BuildRouter returns a RouterRegistry for register grouped routing. BuildRouter(errHandleMiddleware Middleware) RouterRegistry // contains filtered or unexported methods }
RouterContext is a fasthttp request url routing context.
func NewRouterContext ¶
func NewRouterContext( urlPrefix string, reverseRouter UrlFor, ) (ctx RouterContext)
NewRouterContext returns a RouterContext.
type RouterRegistry ¶
type RouterRegistry interface { RouterContext // Name returns the current group name. Name() string // ToContext returns the current group name. ToContext() RouterContext // Register is a registration method for http request. Register( name string, path string, params []string, handler Router, middlewares []Middleware, methods ...string, ) // RegisterNested is a registration method for http request with a router generator. RegisterNested( name string, path string, params []string, routerGenerator NestedRouter, middlewares []Middleware, methods ...string, ) // Wrap returns a child RouterRegistry with specified name and path. Wrap(name string, path string, middlewares ...Middleware) RouterRegistry // Handler is a handler method that process incoming requests. // It implements the Router interface. Handler(ctx *fasthttp.RequestCtx) }
RouterRegistry is a fasthttp request url routing builder.
type UrlFor ¶
type UrlFor interface { UrlResolver // Add registers name, parameter, and URL for UrlResolver. // If a duplicate name exists, an error is returned instead of registering. Add(urlName, urlAddr string, params ...string) (string, error) // MustAdd registers name, parameter, and URL for UrlResolver. // If a duplicate name exists, it panics. MustAdd(urlName, urlAddr string, params ...string) string // AddGr registers name, parameter, and URL for UrlResolver with nested group infos. // If a duplicate name exists, an error is returned instead of registering. AddGr(urlName, urlAddr string, groupNames, groupAddrs []string, params ...string) (string, error) // MustAddGr registers name, parameter, and URL for UrlResolver with nested group infos. // If a duplicate name exists, it panics. MustAddGr(urlName, urlAddr string, groupNames, groupAddrs []string, params ...string) string // Clear clears all registered reverse-routing infos. Clear() // String returns summarized info of registered reverse-routing infos. String() string // ToResolver returns a UrlResolver. ToResolver() UrlResolver }
UrlFor is a reverse-routing utility that stores the handler information.
type UrlResolver ¶
type UrlResolver interface { // Get is a resolver function that takes a name and parameters and returns a URL. If the URL is not found, it panics. Get(urlName string, params ...string) string // Reverse is a resolver function that takes a name and parameters and returns a URL. Reverse(urlName string, params ...string) (string, error) // ReverseWithParams is a resolver function that takes a name and parameters and returns a URL. ReverseWithParams(urlName string, params []string) (string, error) // MustReverse is a resolver function that takes a name and parameters and returns a URL. If the URL is not found, it panics. MustReverse(urlName string, params ...string) string // MustReverseWithParams is a resolver function that takes a name and parameters and returns a URL. If the URL is not found, it panics. MustReverseWithParams(urlName string, params []string) string }
UrlResolver is a URL resolver utility that stores the handler information registered by UrlFor.