本文整理匯總了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"))
}