router.go 747 B

12345678910111213141516171819202122232425262728293031
  1. package init_serve
  2. import (
  3. "github.com/gin-gonic/gin"
  4. _ "hongze/hongze_yb_en_api/docs"
  5. "hongze/hongze_yb_en_api/global"
  6. "hongze/hongze_yb_en_api/middleware"
  7. "hongze/hongze_yb_en_api/routers"
  8. )
  9. // InitRouter 初始化路由
  10. func InitRouter() (r *gin.Engine) {
  11. //设置
  12. gin.SetMode(global.CONFIG.Serve.RunMode)
  13. // 1.创建路由
  14. r = gin.Default()
  15. r.Use(middleware.Cors())
  16. //r.Use(gin.Recovery())
  17. r.Use(middleware.Recover())
  18. // 公共的中间件
  19. r.Use(middleware.Common())
  20. //swagger界面访问地址 http://localhost:8390/swagger/index.html
  21. // r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
  22. rBase := r.Group("api/")
  23. routers.InitAuth(rBase)
  24. routers.InitReport(rBase)
  25. routers.InitPublic(rBase)
  26. return
  27. }