func main() { runtime.GOMAXPROCS(runtime.NumCPU()) migrate() router := gin.Default() router.Use(errorHandler()) router.Use(panicHandler()) // templates router.LoadHTMLGlob("templates/*") router.GET("/login", controller.Users.Login) router.GET("/logout", controller.Users.Logout) router.POST("/login", controller.Users.Authorize) router.GET("/auth", controller.OAuth2.Auth) router.POST("/token", controller.OAuth2.Token) revyapp := router.Group("/revy") revyapp.GET("/callback", controller.Revy.Callback) api := router.Group("/", validateToken()) api.GET("/users/me", controller.Users.Me) api.GET("/smells", todo) api.GET("/statuses", todo) api.GET("/repos", controller.Repos.List) api.POST("/repos", controller.Repos.Create) api.GET("/repos/:repo_id", findRepo(), controller.Repos.Show) api.PATCH("/repos/:repo_id", findRepo(), controller.Repos.Update) api.DELETE("/repos/:repo_id", findRepo(), controller.Repos.Delete) reposApi := api.Group("/repos/:repo_id", findRepo()) { reposApi.GET("/reviews", controller.Reviews.List) reposApi.POST("/reviews", controller.Reviews.Create) reposApi.GET("/reviews/:review_id", controller.Reviews.Show) reposApi.PATCH("/reviews/:review_id", findReview(), controller.Reviews.Update) reposApi.DELETE("/reviews/:review_id", findReview(), controller.Reviews.Delete) } reviewsApi := reposApi.Group("/reviews/:review_id", findReview()) { reviewsApi.GET("/comments", controller.Comments.List) reviewsApi.POST("/comments", controller.Comments.Create) reviewsApi.GET("/comments/:comment_id", todo) reviewsApi.PUT("/comments/:comment_id", todo) reviewsApi.DELETE("/comments/:comment_id", todo) } log.Fatal(http.ListenAndServe(":"+port(), router)) database.GetDB().Close() database.GetRedisPool().Close() }
func init() { var err error max := maxAge() store, err = NewRediStoreWithPool(database.GetRedisPool(), []byte("secret-key")) if err != nil { panic(err) } store.SetMaxAge(max) }