From 8c3b59d622d526a3728f0588dee5359d1ddec209 Mon Sep 17 00:00:00 2001 From: nite07 Date: Thu, 5 Dec 2024 03:23:41 +0800 Subject: [PATCH] modify router --- server/route.go | 10 +++++++--- server/server.go | 1 - 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server/route.go b/server/route.go index f15105c..4f6fb9e 100644 --- a/server/route.go +++ b/server/route.go @@ -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)) diff --git a/server/server.go b/server/server.go index 3d11ea2..1bbdffa 100644 --- a/server/server.go +++ b/server/server.go @@ -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))