router.go 720 B

123456789101112131415161718192021222324252627282930
  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. return
  26. }