当前位置: 首页>>代码示例>>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;未经允许,请勿转载。