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
()
| 492 | // Here, the routes registered in the subrouter won't be tested if the host |
| 493 | // doesn't match. |
| 494 | func (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 |