modify router

This commit is contained in:
Nite07 2024-12-05 03:23:41 +08:00
parent 6d212864c5
commit 8c3b59d622
2 changed files with 7 additions and 4 deletions

View File

@ -39,6 +39,8 @@ func initRoute(app *gin.Engine) {
}
func initFrontend(app *gin.Engine) {
app.Use(middleware.Logger())
// Load static files
staticFs, err := fs.Sub(frontendFS, "static")
if err != nil {
@ -167,7 +169,9 @@ func initApi(app *gin.Engine) {
apiGroup := app.Group("/api")
GameInfoGroup := apiGroup.Group("/game")
GameInfoGroup.Use(middleware.Logger())
GameItemGroup := GameInfoGroup.Group("/raw")
GameItemGroup.Use(middleware.Logger())
GameItemGroup.GET("/unorganized", handler.GetUnorganizedGameItemsHandler)
GameItemGroup.POST("/organize", middleware.Auth(), handler.OrganizeGameItemHandler)
@ -181,10 +185,10 @@ func initApi(app *gin.Engine) {
GameInfoGroup.GET("/id/:id", handler.GetGameInfoByIDHandler)
GameInfoGroup.DELETE("/id/:id", middleware.Auth(), handler.DeleteGameInfoHandler)
apiGroup.GET("/popular/:type", handler.GetPopularGameInfosHandler)
apiGroup.GET("/popular/:type", middleware.Logger(), handler.GetPopularGameInfosHandler)
apiGroup.GET("/healthcheck", handler.HealthCheckHandler)
apiGroup.GET("/author", handler.GetAllAuthorsHandler)
apiGroup.POST("/clean", middleware.Auth(), handler.CleanGameHandler)
apiGroup.GET("/author", middleware.Logger(), handler.GetAllAuthorsHandler)
apiGroup.POST("/clean", middleware.Logger(), middleware.Auth(), handler.CleanGameHandler)
docs.SwaggerInfo.BasePath = "/api"
apiGroup.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))

View File

@ -26,7 +26,6 @@ func Run() {
gin.SetMode(gin.ReleaseMode)
gin.DefaultWriter = io.Discard
app := gin.New()
app.Use(middleware.Logger())
app.Use(middleware.Recovery())
initRoute(app)
log.Logger.Info("Server running", zap.String("port", config.Config.Server.Port))