package mux

Import Path
	github.com/gorilla/mux (on go.dev)

Dependency Relation
	imports 10 packages, and imported by 3 packages

Involved Source Files
	d-> doc.go
	    middleware.go
	    mux.go
	    regexp.go
	    route.go
	    test_helpers.go

Exported Type Names

type BuildVarsFunc (func) BuildVarsFunc is the function signature used by custom build variable functions (which can modify route variables before a route's URL is built). func (*Route).BuildVarsFunc(f BuildVarsFunc) *Route func (*Router).BuildVarsFunc(f BuildVarsFunc) *Route
type MatcherFunc (func) MatcherFunc is the function signature used by custom matchers. (T) Match(r *http.Request, match *RouteMatch) bool func (*Route).MatcherFunc(f MatcherFunc) *Route func (*Router).MatcherFunc(f MatcherFunc) *Route
type MiddlewareFunc (func) MiddlewareFunc is a function which receives an http.Handler and returns another http.Handler. Typically, the returned handler is a closure which does something with the http.ResponseWriter and http.Request passed to it, and then calls the handler passed as parameter to the MiddlewareFunc. (T) Middleware(handler http.Handler) http.Handler func CORSMethodMiddleware(r *Router) MiddlewareFunc func (*Router).Use(mwf ...MiddlewareFunc)
type Route (struct) Route stores information to match a request and build URLs. (*T) BuildOnly() *Route (*T) BuildVarsFunc(f BuildVarsFunc) *Route (*T) GetError() error (*T) GetHandler() http.Handler (*T) GetHostTemplate() (string, error) (*T) GetMethods() ([]string, error) (*T) GetName() string (*T) GetPathRegexp() (string, error) (*T) GetPathTemplate() (string, error) (*T) GetQueriesRegexp() ([]string, error) (*T) GetQueriesTemplates() ([]string, error) (*T) Handler(handler http.Handler) *Route (*T) HandlerFunc(f func(http.ResponseWriter, *http.Request)) *Route (*T) Headers(pairs ...string) *Route (*T) HeadersRegexp(pairs ...string) *Route (*T) Host(tpl string) *Route (*T) Match(req *http.Request, match *RouteMatch) bool (*T) MatcherFunc(f MatcherFunc) *Route (*T) Methods(methods ...string) *Route (*T) Name(name string) *Route (*T) Path(tpl string) *Route (*T) PathPrefix(tpl string) *Route (*T) Queries(pairs ...string) *Route (*T) Schemes(schemes ...string) *Route (*T) SkipClean() bool (*T) Subrouter() *Router (*T) URL(pairs ...string) (*url.URL, error) (*T) URLHost(pairs ...string) (*url.URL, error) (*T) URLPath(pairs ...string) (*url.URL, error) func CurrentRoute(r *http.Request) *Route func (*Route).BuildOnly() *Route func (*Route).BuildVarsFunc(f BuildVarsFunc) *Route func (*Route).Handler(handler http.Handler) *Route func (*Route).HandlerFunc(f func(http.ResponseWriter, *http.Request)) *Route func (*Route).Headers(pairs ...string) *Route func (*Route).HeadersRegexp(pairs ...string) *Route func (*Route).Host(tpl string) *Route func (*Route).MatcherFunc(f MatcherFunc) *Route func (*Route).Methods(methods ...string) *Route func (*Route).Name(name string) *Route func (*Route).Path(tpl string) *Route func (*Route).PathPrefix(tpl string) *Route func (*Route).Queries(pairs ...string) *Route func (*Route).Schemes(schemes ...string) *Route func (*Router).BuildVarsFunc(f BuildVarsFunc) *Route func (*Router).Get(name string) *Route func (*Router).GetRoute(name string) *Route func (*Router).Handle(path string, handler http.Handler) *Route func (*Router).HandleFunc(path string, f func(http.ResponseWriter, *http.Request)) *Route func (*Router).Headers(pairs ...string) *Route func (*Router).Host(tpl string) *Route func (*Router).MatcherFunc(f MatcherFunc) *Route func (*Router).Methods(methods ...string) *Route func (*Router).Name(name string) *Route func (*Router).NewRoute() *Route func (*Router).Path(tpl string) *Route func (*Router).PathPrefix(tpl string) *Route func (*Router).Queries(pairs ...string) *Route func (*Router).Schemes(schemes ...string) *Route
type RouteMatch (struct) RouteMatch stores information about a matched route. Handler http.Handler MatchErr error Route *Route Vars map[string]string func MatcherFunc.Match(r *http.Request, match *RouteMatch) bool func (*Route).Match(req *http.Request, match *RouteMatch) bool func (*Router).Match(req *http.Request, match *RouteMatch) bool
type Router (struct) Router registers routes to be matched and dispatches a handler. It implements the http.Handler interface, so it can be registered to serve requests: var router = mux.NewRouter() func main() { http.Handle("/", router) } Or, for Google App Engine, register it in a init() function: func init() { http.Handle("/", router) } This will send all incoming requests to the router. KeepContext bool MethodNotAllowedHandler http.Handler NotFoundHandler http.Handler (*T) BuildVarsFunc(f BuildVarsFunc) *Route (*T) Get(name string) *Route (*T) GetRoute(name string) *Route (*T) Handle(path string, handler http.Handler) *Route (*T) HandleFunc(path string, f func(http.ResponseWriter, *http.Request)) *Route (*T) Headers(pairs ...string) *Route (*T) Host(tpl string) *Route (*T) Match(req *http.Request, match *RouteMatch) bool (*T) MatcherFunc(f MatcherFunc) *Route (*T) Methods(methods ...string) *Route (*T) Name(name string) *Route (*T) NewRoute() *Route (*T) Path(tpl string) *Route (*T) PathPrefix(tpl string) *Route (*T) Queries(pairs ...string) *Route (*T) Schemes(schemes ...string) *Route (*T) ServeHTTP(w http.ResponseWriter, req *http.Request) (*T) SkipClean(value bool) *Router (*T) StrictSlash(value bool) *Router (*T) Use(mwf ...MiddlewareFunc) (*T) UseEncodedPath() *Router (*T) Walk(walkFn WalkFunc) error *T : net/http.Handler func NewRouter() *Router func (*Route).Subrouter() *Router func (*Router).SkipClean(value bool) *Router func (*Router).StrictSlash(value bool) *Router func (*Router).UseEncodedPath() *Router func CORSMethodMiddleware(r *Router) MiddlewareFunc func fs5-gestiondesocios-backend/src/api/routes.SetGamesRoutes(r *Router) func fs5-gestiondesocios-backend/src/api/routes.SetUsersRoutes(r *Router)
type WalkFunc (func) WalkFunc is the type of the function called for each route visited by Walk. At every invocation, it is given the current route, and the current router, and a list of ancestor routes that lead to the current route. func (*Router).Walk(walkFn WalkFunc) error
Exported Values
func CORSMethodMiddleware(r *Router) MiddlewareFunc CORSMethodMiddleware automatically sets the Access-Control-Allow-Methods response header on requests for routes that have an OPTIONS method matcher to all the method matchers on the route. Routes that do not explicitly handle OPTIONS requests will not be processed by the middleware. See examples for usage.
func CurrentRoute(r *http.Request) *Route CurrentRoute returns the matched route for the current request, if any. This only works when called inside the handler of the matched route because the matched route is stored in the request context which is cleared after the handler returns.
var ErrMethodMismatch error ErrMethodMismatch is returned when the method in the request does not match the method defined against the route.
var ErrNotFound error ErrNotFound is returned when no route match is found.
func NewRouter() *Router NewRouter returns a new router instance.
func SetURLVars(r *http.Request, val map[string]string) *http.Request SetURLVars sets the URL variables for the given request, to be accessed via mux.Vars for testing route behaviour. Arguments are not modified, a shallow copy is returned. This API should only be used for testing purposes; it provides a way to inject variables into the request context. Alternatively, URL variables can be set by making a route that captures the required variables, starting a server and sending the request to that server.
var SkipRouter error SkipRouter is used as a return value from WalkFuncs to indicate that the router that walk is about to descend down to should be skipped.
func Vars(r *http.Request) map[string]string Vars returns the route variables for the current request, if any.