MCPcopy
hub / github.com/gorilla/mux / Subrouter

Method Subrouter

route.go:494–499  ·  route.go::Route.Subrouter

Subrouter ------------------------------------------------------------------ Subrouter creates a subrouter for the route. It will test the inner routes only if the parent route matched. For example: r := mux.NewRouter().NewRoute() s := r.Host("www.example.com").Subrouter() s.HandleFunc("/produc

()

Source from the content-addressed store, hash-verified

492// Here, the routes registered in the subrouter won't be tested if the host
493// doesn't match.
494func (r *Route) Subrouter() *Router {
495 // initialize a subrouter with a copy of the parent route's configuration
496 router := &Router{routeConf: copyRouteConf(r.routeConf), namedRoutes: r.namedRoutes}
497 r.addMatcher(router)
498 return router
499}
500
501// ----------------------------------------------------------------------------
502// URL building

Callers 15

TestMiddlewareSubrouterFunction · 0.80
TestBuildVarsFuncFunction · 0.80
TestSubRouterFunction · 0.80
TestNamedRoutesFunction · 0.80
TestStrictSlashFunction · 0.80
TestWalkNestedFunction · 0.80
TestWalkSubroutersFunction · 0.80
TestWalkErrorMatcherFunction · 0.80

Calls 2

addMatcherMethod · 0.95
copyRouteConfFunction · 0.85

Tested by 15

TestMiddlewareSubrouterFunction · 0.64
TestBuildVarsFuncFunction · 0.64
TestSubRouterFunction · 0.64
TestNamedRoutesFunction · 0.64
TestStrictSlashFunction · 0.64
TestWalkNestedFunction · 0.64
TestWalkSubroutersFunction · 0.64
TestWalkErrorMatcherFunction · 0.64