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


Golang Engine.NoRoute方法代碼示例

本文整理匯總了Golang中github.com/gin-gonic/gin.Engine.NoRoute方法的典型用法代碼示例。如果您正苦於以下問題:Golang Engine.NoRoute方法的具體用法?Golang Engine.NoRoute怎麽用?Golang Engine.NoRoute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/gin-gonic/gin.Engine的用法示例。


在下文中一共展示了Engine.NoRoute方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Register

// Register registers the route handlers for this controller
func (f *FrontController) Register(r *gin.Engine) {
	front := r.Group("/")
	{
		front.GET("/", f.getIndex)
		front.GET("/healthcheck", f.getHealthCheck)
	}

	r.NoRoute(f.getNotFound)
}
開發者ID:Exquance,項目名稱:phabulous,代碼行數:10,代碼來源:front.go

示例2: LoadPage

func LoadPage(parentRoute *gin.Engine) {
	//type Page struct {
	//    Title string
	//}

	parentRoute.SetHTMLTemplate(template.Must(template.ParseFiles("frontend/canjs/templates/message.html", "frontend/canjs/templates/app.html", "frontend/canjs/templates/base.html", "frontend/canjs/templates/404.html")))
	log.Debug("url : " + config.StaticUrl)
	log.Debug("guid : " + config.Guid)
	log.Debug("path : " + staticPath)
	parentRoute.Static(config.StaticUrl+"/"+config.Guid, staticPath)
	// route.ServeFiles doesn't exist in the current version of gin. If you want to use this, use the 59d949d35080b83864dbeafadecef112d46aaeee.
	//parentRoute.ServeFiles(config.StaticUrl+"/"+config.Guid+"/*filepath", http.Dir(staticPath))
	parentRoute.NoRoute(func(c *gin.Context) {
		c.HTML(404, "404.html", map[string]string{"language": config.DefaultLanguage, "title": config.Title})
	})

	route.Route(parentRoute.Group(""))
}
開發者ID:wangmingjob,項目名稱:goyangi,代碼行數:18,代碼來源:index.go

示例3: RegisterRoute

func RegisterRoute(r *gin.Engine) {
	loadHTMLGlob(r, path.Join(config.GLOBAL_CONFIG.TemplatePath, "*"), registerDefaultFunctions)

	r.GET("/", IndexAction)
	r.GET("/post/:postId", ShowPostAction)

	r.POST("/login", LoginAction)
	r.POST("/register", RegisterAction)
	r.GET("/logout", LogoutAction)

	r.GET("/new_post", ShowNewPostPageAction)
	r.POST("/posts", NewPostAction)

	// admin
	r.GET("/admin/users", controllers.ShowUsersAction)

	r.Static("/statics", config.GLOBAL_CONFIG.StaticPath)

	r.NoRoute(NoRouteHandler)
}
開發者ID:goodplayer,項目名稱:Princess,代碼行數:20,代碼來源:route.go

示例4: Route

// Declare all routes
func Route(r *gin.Engine) {
	r.GET("/api/ping", func(c *gin.Context) {
		c.String(200, "PONG")
	})

	r.NoRoute(servePublic)

	// set up the namespace
	api := r.Group("/api")

	func(api *gin.RouterGroup) {
		api.POST("/login", login)
		api.POST("/logout", logout)
	}(api.Group("/auth"))

	api.Use(authentication)

	api.GET("/ws", sockets.Handler)

	api.GET("/info", getSystemInfo)
	api.GET("/upgrade", checkUpgrade)
	api.POST("/upgrade", doUpgrade)

	func(api *gin.RouterGroup) {
		api.GET("", getUser)
		// api.PUT("/user", misc.UpdateUser)

		api.GET("/tokens", getAPITokens)
		api.POST("/tokens", createAPIToken)
		api.DELETE("/tokens/:token_id", expireAPIToken)
	}(api.Group("/user"))

	api.GET("/projects", projects.GetProjects)
	api.POST("/projects", projects.AddProject)
	api.GET("/events", getEvents)

	api.GET("/users", getUsers)
	api.POST("/users", addUser)
	api.GET("/users/:user_id", getUserMiddleware, getUser)
	api.PUT("/users/:user_id", getUserMiddleware, updateUser)
	api.POST("/users/:user_id/password", getUserMiddleware, updateUserPassword)
	api.DELETE("/users/:user_id", getUserMiddleware, deleteUser)

	func(api *gin.RouterGroup) {
		api.Use(projects.ProjectMiddleware)

		api.GET("", projects.GetProject)
		api.PUT("", projects.MustBeAdmin, projects.UpdateProject)
		api.DELETE("", projects.MustBeAdmin, projects.DeleteProject)

		api.GET("/events", getEvents)

		api.GET("/users", projects.GetUsers)
		api.POST("/users", projects.MustBeAdmin, projects.AddUser)
		api.POST("/users/:user_id/admin", projects.MustBeAdmin, projects.UserMiddleware, projects.MakeUserAdmin)
		api.DELETE("/users/:user_id/admin", projects.MustBeAdmin, projects.UserMiddleware, projects.MakeUserAdmin)
		api.DELETE("/users/:user_id", projects.MustBeAdmin, projects.UserMiddleware, projects.RemoveUser)

		api.GET("/keys", projects.GetKeys)
		api.POST("/keys", projects.AddKey)
		api.PUT("/keys/:key_id", projects.KeyMiddleware, projects.UpdateKey)
		api.DELETE("/keys/:key_id", projects.KeyMiddleware, projects.RemoveKey)

		api.GET("/repositories", projects.GetRepositories)
		api.POST("/repositories", projects.AddRepository)
		api.PUT("/repositories/:repository_id", projects.RepositoryMiddleware, projects.UpdateRepository)
		api.DELETE("/repositories/:repository_id", projects.RepositoryMiddleware, projects.RemoveRepository)

		api.GET("/inventory", projects.GetInventory)
		api.POST("/inventory", projects.AddInventory)
		api.PUT("/inventory/:inventory_id", projects.InventoryMiddleware, projects.UpdateInventory)
		api.DELETE("/inventory/:inventory_id", projects.InventoryMiddleware, projects.RemoveInventory)

		api.GET("/environment", projects.GetEnvironment)
		api.POST("/environment", projects.AddEnvironment)
		api.PUT("/environment/:environment_id", projects.EnvironmentMiddleware, projects.UpdateEnvironment)
		api.DELETE("/environment/:environment_id", projects.EnvironmentMiddleware, projects.RemoveEnvironment)

		api.GET("/templates", projects.GetTemplates)
		api.POST("/templates", projects.AddTemplate)
		api.PUT("/templates/:template_id", projects.TemplatesMiddleware, projects.UpdateTemplate)
		api.DELETE("/templates/:template_id", projects.TemplatesMiddleware, projects.RemoveTemplate)

		api.GET("/tasks", tasks.GetAll)
		api.POST("/tasks", tasks.AddTask)
		api.GET("/tasks/:task_id/output", tasks.GetTaskMiddleware, tasks.GetTaskOutput)
		api.DELETE("/tasks/:task_id", tasks.GetTaskMiddleware, tasks.RemoveTask)
	}(api.Group("/project/:project_id"))
}
開發者ID:pselibas,項目名稱:semaphore,代碼行數:90,代碼來源:router.go


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