router.go 627 B

12345678910111213141516171819202122
  1. package app
  2. import (
  3. middleware "Ic_ouath/app/middlewares"
  4. "Ic_ouath/app/routers"
  5. "Ic_ouath/configs"
  6. _ "Ic_ouath/docs"
  7. "github.com/gin-gonic/gin"
  8. swaggerFiles "github.com/swaggo/files"
  9. ginSwagger "github.com/swaggo/gin-swagger"
  10. )
  11. func InitRouter() error {
  12. engine := gin.New()
  13. //记录日志
  14. // engine.Use(middleware.LoggerToFile())
  15. engine.Use(middleware.Cors())
  16. engine.GET("/swagger/*any", ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "NAME_OF_ENV_VARIABLE"))
  17. gin.SetMode(configs.Config.GetString("server.mode"))
  18. routers.UserRouter(engine)
  19. return engine.Run(configs.Config.GetString("server.port"))
  20. }