本文整理匯總了Golang中github.com/gorilla/mux.Router.StrictSlash方法的典型用法代碼示例。如果您正苦於以下問題:Golang Router.StrictSlash方法的具體用法?Golang Router.StrictSlash怎麽用?Golang Router.StrictSlash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gorilla/mux.Router
的用法示例。
在下文中一共展示了Router.StrictSlash方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: HandleSubrouter
// 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)
}
示例2: RegisterTaskyHandlers
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")
}
示例3: SetPolymerAppRoutes
// 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
}
示例4: handlePluginRoutes
// 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)
}