當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Router.StrictSlash方法代碼示例

本文整理匯總了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)
}
開發者ID:kaggis,項目名稱:argo-web-api,代碼行數:12,代碼來源:routing.go

示例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")
}
開發者ID:golang-alex-alex2006hw,項目名稱:go-tasky,代碼行數:16,代碼來源:tasky.go

示例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
}
開發者ID:malloc-fi,項目名稱:vantaa,代碼行數:19,代碼來源:polymer.go

示例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)
}
開發者ID:rhinoman,項目名稱:wikifeat,代碼行數:7,代碼來源:plugin_router.go


注:本文中的github.com/gorilla/mux.Router.StrictSlash方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。