Route creates a new Mux and mounts it along the `pattern` as a subrouter. Effectively, this is a short-hand call to Mount. See _examples/.
(pattern string, fn func(r Router))
| 270 | // Route creates a new Mux and mounts it along the `pattern` as a subrouter. |
| 271 | // Effectively, this is a short-hand call to Mount. See _examples/. |
| 272 | func (mx *Mux) Route(pattern string, fn func(r Router)) Router { |
| 273 | if fn == nil { |
| 274 | panic(fmt.Sprintf("chi: attempting to Route() a nil subrouter on '%s'", pattern)) |
| 275 | } |
| 276 | subRouter := NewRouter() |
| 277 | fn(subRouter) |
| 278 | mx.Mount(pattern, subRouter) |
| 279 | return subRouter |
| 280 | } |
| 281 | |
| 282 | // Mount attaches another http.Handler or chi Router as a subrouter along a routing |
| 283 | // path. It's very useful to split up a large API as many independent routers and |