本文整理汇总了Golang中github.com/dimfeld/httptreemux.TreeMux类的典型用法代码示例。如果您正苦于以下问题:Golang TreeMux类的具体用法?Golang TreeMux怎么用?Golang TreeMux使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TreeMux类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Register
func (routeDir *RouteDirectory) Register(router *httptreemux.TreeMux) {
var keys []DirectoryKey
routes := routeDir.Routes
for k := range routes {
keys = append(keys, k)
}
for _, k := range keys {
route := routes[k]
if route.Visible {
handler := route.Handler
if route.CheckPermissions {
permissionGate := NewPermissionGate(k.Ressource, k.Method, routeDir.accountInter, routeDir.render, route.Handler)
handler = permissionGate.Handler
}
route.EffectiveHandler = handler
routes[k] = route
router.Handle(route.Method, route.Path, httptreemux.HandlerFunc(handler))
}
}
}
开发者ID:optimuse,项目名称:zest,代码行数:26,代码来源:route_directory.go
示例2: InitializeBlog
func InitializeBlog(router *httptreemux.TreeMux) {
// For index
router.GET("/", indexHandler)
router.GET("/:slug/", postHandler)
router.GET("/page/:number/", indexHandler)
// For author
router.GET("/author/:slug/", authorHandler)
router.GET("/author/:slug/:function/", authorHandler)
router.GET("/author/:slug/:function/:number/", authorHandler)
// For tag
router.GET("/tag/:slug/", tagHandler)
router.GET("/tag/:slug/:function/", tagHandler)
router.GET("/tag/:slug/:function/:number/", tagHandler)
// For serving asset files
router.GET("/assets/*filepath", assetsHandler)
router.GET("/images/*filepath", imagesHandler)
router.GET("/content/images/*filepath", imagesHandler) // This is here to keep compatibility with Ghost
router.GET("/public/*filepath", publicHandler)
}
开发者ID:troyxmccall,项目名称:goblahg,代码行数:19,代码来源:blog.go
示例3: InitializeAdmin
func InitializeAdmin(router *httptreemux.TreeMux) {
// For admin panel
router.GET("/admin/", adminHandler)
router.GET("/admin/login/", getLoginHandler)
router.POST("/admin/login/", postLoginHandler)
router.GET("/admin/register/", getRegistrationHandler)
router.POST("/admin/register/", postRegistrationHandler)
router.GET("/admin/logout/", logoutHandler)
router.GET("/admin/*filepath", adminFileHandler)
// For admin API (no trailing slash)
// Posts
router.GET("/admin/api/posts/:number", apiPostsHandler)
// Post
router.GET("/admin/api/post/:id", getApiPostHandler)
router.POST("/admin/api/post", postApiPostHandler)
router.PATCH("/admin/api/post", patchApiPostHandler)
router.DELETE("/admin/api/post/:id", deleteApiPostHandler)
// Upload
router.POST("/admin/api/upload", apiUploadHandler)
// Images
router.GET("/admin/api/images/:number", apiImagesHandler)
router.DELETE("/admin/api/image", deleteApiImageHandler)
// Blog
router.GET("/admin/api/blog", getApiBlogHandler)
router.PATCH("/admin/api/blog", patchApiBlogHandler)
// User
router.GET("/admin/api/user/:id", getApiUserHandler)
router.PATCH("/admin/api/user", patchApiUserHandler)
// User id
router.GET("/admin/api/userid", getApiUserIdHandler)
}
开发者ID:troyxmccall,项目名称:goblahg,代码行数:32,代码来源:admin.go
示例4: InitializePages
func InitializePages(router *httptreemux.TreeMux) {
// For serving standalone projects or pages saved in in content/pages
router.GET("/pages/*filepath", pagesHandler)
}
开发者ID:itkpi,项目名称:journey,代码行数:4,代码来源:pages.go
注:本文中的github.com/dimfeld/httptreemux.TreeMux类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论