// Setup sub routes for more efficient routing of requests inside of gorilla mux.
Setup sub routes for more efficient routing of requests inside of gorilla mux.
// Setup sub routes for more efficient routing of requests inside of gorilla mux .
func (m *Milo) SubRoute(prefix, path string, methods []string, hf http.HandlerFunc) {
	var subRouter *mux.Router
	var ok bool
	subRouter, ok = m.subRoutes[prefix]
	if !ok {
		subRouter = m.router.PathPrefix(prefix).Subrouter()
		m.subRoutes[prefix] = subRouter
	}
	fn := func(w http.ResponseWriter, r *http.Request) {
		m.runRoute(w, r, hf, prefix+path)
	}
	if methods != nil {
		subRouter.Path(path).Methods(methods...).HandlerFunc(fn)
	} else {
		subRouter.Path(path).HandlerFunc(fn)
	}
}
func ( m * Milo ) SubRoute ( prefix , path string , methods [ ] string , hf http . HandlerFunc ) { var subRouter * mux . Router var ok bool subRouter , ok = m . subRoutes [ prefix ] if ! ok { subRouter = m . router . PathPrefix ( prefix ) . Subrouter ( ) m . subRoutes [ prefix ] = subRouter } fn := func ( w http . ResponseWriter , r * http . Request ) { m . runRoute ( w , r , hf , prefix + path ) } if methods != nil { subRouter . Path ( path ) . Methods ( methods ... ) . HandlerFunc ( fn ) } else { subRouter . Path ( path ) . HandlerFunc ( fn ) } }
Setup sub routes for more efficient routing of requests inside of gorilla mux.
Setup sub routes for more efficient routing of requests inside of gorilla mux .