Documentation
¶
Overview ¶
Package routing provides HTTP routing abstractions including router, middleware, and route parameter interfaces.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextKey ¶
type ContextKey string
ContextKey represents strings to be used in Context objects. From the docs:
"The provided key must be comparable and should not be of type string or any other built-in type to avoid collisions between packages using context."
type Middleware ¶
Middleware is a type alias for a middleware handler function.
type RouteParamManager ¶
type RouteParamManager interface {
BuildRouteParamIDFetcher(logger logging.Logger, key, logDescription string) func(req *http.Request) uint64
BuildRouteParamStringIDFetcher(key string) func(req *http.Request) string
}
RouteParamManager builds route param fetchers for a compatible router.
type Router ¶
type Router interface {
Routes() []*Route
Handler() http.Handler
Handle(pattern string, handler http.Handler)
HandleFunc(pattern string, handler http.HandlerFunc)
WithMiddleware(middleware ...Middleware) Router
Route(pattern string, fn func(r Router)) Router
Connect(pattern string, handler http.HandlerFunc)
Delete(pattern string, handler http.HandlerFunc)
Get(pattern string, handler http.HandlerFunc)
Head(pattern string, handler http.HandlerFunc)
Options(pattern string, handler http.HandlerFunc)
Patch(pattern string, handler http.HandlerFunc)
Post(pattern string, handler http.HandlerFunc)
Put(pattern string, handler http.HandlerFunc)
Trace(pattern string, handler http.HandlerFunc)
AddRoute(method, path string, handler http.HandlerFunc, middleware ...Middleware) error
}
Router defines the contract between routing library and caller.
Click to show internal directories.
Click to hide internal directories.