Documentation
¶
Overview ¶
Package routing provides a small route registry backed by net/http ServeMux matching.
Index ¶
- type MiddlewareFunc
- type Route
- func (rt *Route) GetHandler() http.Handler
- func (rt *Route) GetMethods() ([]string, error)
- func (rt *Route) GetName() string
- func (rt *Route) GetPathTemplate() (string, error)
- func (rt *Route) Handler(handler http.Handler) *Route
- func (rt *Route) HandlerFunc(handler func(http.ResponseWriter, *http.Request)) *Route
- func (rt *Route) Methods(methods ...string) *Route
- func (rt *Route) Name(name string) *Route
- type Router
- func (r *Router) CloneExcluding(names map[string]bool) *Router
- func (r *Router) Get(name string) *Route
- func (r *Router) Handle(pattern string, handler http.Handler)
- func (r *Router) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
- func (r *Router) Path(path string) *Route
- func (r *Router) PathPrefix(prefix string) *Route
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) Use(middleware ...MiddlewareFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MiddlewareFunc ¶
MiddlewareFunc wraps an HTTP handler with cross-cutting behavior.
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route is a registered path or prefix route.
func (*Route) GetHandler ¶
GetHandler returns the route handler.
func (*Route) GetMethods ¶
GetMethods returns the configured HTTP methods.
func (*Route) GetPathTemplate ¶
GetPathTemplate returns the route path template.
func (*Route) HandlerFunc ¶
HandlerFunc assigns the HTTP handler function for the route.
type Router ¶
type Router struct {
NotFoundHandler http.Handler
MethodNotAllowedHandler http.Handler
// contains filtered or unexported fields
}
Router stores named routes and dispatches requests through a net/http ServeMux.
func (*Router) CloneExcluding ¶
CloneExcluding returns a router clone without the named routes in names.
func (*Router) HandleFunc ¶
HandleFunc registers handler for an exact path pattern.
func (*Router) PathPrefix ¶
PathPrefix registers a prefix route and returns it for further configuration.
func (*Router) Use ¶
func (r *Router) Use(middleware ...MiddlewareFunc)
Use appends global middleware applied to all registered route handlers.