router.go 705 B

1234567891011121314151617181920212223
  1. package app
  2. import (
  3. "github.com/gin-gonic/gin"
  4. swaggerFiles "github.com/swaggo/files"
  5. ginSwagger "github.com/swaggo/gin-swagger"
  6. "lot_interlligentControl/app/middlewares"
  7. "lot_interlligentControl/app/routers"
  8. _ "lot_interlligentControl/docs"
  9. "lot_interlligentControl/global"
  10. )
  11. func InitRouter() error {
  12. engine := gin.New()
  13. engine.GET("/swagger/*any", ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "NAME_OF_ENV_VARIABLE"))
  14. engine.Use(middlewares.LoggerToFile())
  15. engine.Use(middlewares.Cors())
  16. engine.Use(middlewares.LoginMiddleware())
  17. routers.ShopInItRouter(engine)
  18. routers.ServiceNodeRouter(engine)
  19. routers.AdminInirRouter(engine)
  20. return engine.Run(global.ServerSetting.Port)
  21. }