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


Golang Router.ServeFiles方法代碼示例

本文整理匯總了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"))
}
開發者ID:MarvinMenzerath,項目名稱:UpAndRunning2,代碼行數:14,代碼來源:main.go

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

示例3: setupStaticRoutes

func setupStaticRoutes(router *httprouter.Router) {
	router.ServeFiles("/assets/*filepath", http.Dir("assets"))
}
開發者ID:escribano,項目名稱:charon,代碼行數:3,代碼來源:run.go


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