本文整理汇总了Golang中github.com/julienschmidt/httprouter.Router.ServeFiles方法的典型用法代码示例。如果您正苦于以下问题:Golang Router.ServeFiles方法的具体用法?Golang Router.ServeFiles怎么用?Golang Router.ServeFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/julienschmidt/httprouter.Router
的用法示例。
在下文中一共展示了Router.ServeFiles方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: setupWebFrontend
// Setup all routes for Web-Frontend
func setupWebFrontend(router *httprouter.Router) {
// Index
router.GET("/", routes.ViewIndex)
router.GET("/status/:url", routes.ViewIndex)
router.GET("/results/:url", routes.ViewIndex)
// Admin
router.GET("/admin", routes.ViewAdmin)
router.GET("/admin/login", routes.ViewLogin)
// Static Files
router.ServeFiles("/public/*filepath", http.Dir("public"))
}
示例2: AddRoutes
// Add routes to http router
// TODO: Add route description parameters and useage
func AddRoutes(router *httprouter.Router) {
router.ServeFiles("/static/*filepath", http.Dir("./static"))
router.GET("/", CheckAuth(Index))
router.GET("/actions", CheckAuth(Actions))
router.GET("/actions/:ActionId", CheckAuth(ActionById))
//router.POST("/set/:SetId", PostAction)
router.GET("/actions/:ActionId/occurrences", Occurrences)
router.GET("/occurrences/:OccurrenceId", OccurrenceById)
router.POST("/users", PostUser)
router.GET("/auth/login", LoginPage)
router.POST("/auth/login", AuthLogin)
router.POST("/actions/:ActionId", CheckAuth(PostOccurrence))
router.POST("/actions/", CheckAuth(PostAction))
// TODO:
// router.GET("/sets", sets)
// router.GET("/sets/:SetId/actions", actionsFromSet)
}
示例3: setupStaticRoutes
func setupStaticRoutes(router *httprouter.Router) {
router.ServeFiles("/assets/*filepath", http.Dir("assets"))
}