MCPcopy
hub / github.com/go-chi/chi / Route

Method Route

mux.go:272–280  ·  view source on GitHub ↗

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))

Source from the content-addressed store, hash-verified

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/.
272func (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

Callers 2

bigMuxFunction · 0.95

Calls 2

MountMethod · 0.95
NewRouterFunction · 0.85

Tested by 2

bigMuxFunction · 0.76