// HandleSubrouter uses the subrouter for a specific calls and creates a tree of sorts // handling each route with a different subrouter func HandleSubrouter(s *mux.Router, confhandler *respond.ConfHandler) { serviceSubrouter := s.StrictSlash(false).PathPrefix("/{report_name}").Subrouter() serviceSubrouter = respond.PrepAppRoutes(serviceSubrouter, confhandler, appServiceRoutes) groupSubrouter := s.StrictSlash(false).PathPrefix("/{report_name}").Subrouter() groupSubrouter = respond.PrepAppRoutes(groupSubrouter, confhandler, appGroupRoutes) s = respond.PrepAppRoutes(s, confhandler, appRoutesV2) }
func RegisterTaskyHandlers(r *mux.Router) { r.StrictSlash(true) //enables matching a route with or without a trailing slash //Handles /tasky/v1 routes. Create new subrouters off this tr := r.PathPrefix(apiBase).Subrouter() workersRtr := tr.PathPrefix("/workers").Subrouter() workersRtr.HandleFunc("/", handlerListWorkers).Methods("GET") workersRtr.HandleFunc("/{name}", handlerNewTask).Methods("POST") tasksRtr := tr.PathPrefix("/tasks").Subrouter() tasksRtr.HandleFunc("/", handlerListTasks).Methods("GET") // tasksRtr.HandleFunc("/{id:[0-9a-f]+}", handlerGetTaskInfo).Methods("GET") tasksRtr.HandleFunc("/{id:[0-9a-f]+}/status", handlerGetTaskStatus).Methods("GET") tasksRtr.HandleFunc("/{id:[0-9a-f]+}/cancel", handlerCancelTask).Methods("POST") tasksRtr.HandleFunc("/{id:[0-9a-f]+}/result", handlerGetTaskOutput).Methods("GET") }
// SetPolymerAppRoutes sets the path for polymer app func SetPolymerAppRoutes(router *mux.Router) *mux.Router { router = router.StrictSlash(true) if env == "production" { adminAppFiles := http.FileServer(http.Dir("./admin/dist/")) router.PathPrefix("/admin/").Handler(http.StripPrefix("/admin/", adminAppFiles)) } else { adminAppFiles := http.FileServer(http.Dir("./admin/app/")) adminBowerFiles := http.FileServer(http.Dir("./admin/bower_components/")) router.PathPrefix("/admin/bower_components/").Handler(http.StripPrefix("/admin/bower_components/", adminBowerFiles)) router.PathPrefix("/admin").Handler(http.StripPrefix("/admin", adminAppFiles)) router.PathPrefix("/admin/").Handler(http.StripPrefix("/admin/", adminAppFiles)) } return router }
// Plugin "Resources" -- static files and such func handlePluginRoutes(pr *mux.Router) { pr.StrictSlash(true).HandleFunc("/", getPluginList).Methods("GET") pr.PathPrefix("/{plugin-name}/resource/"). Methods("GET"). HandlerFunc(servePluginResource) }