router.go 533 B

123456789101112131415161718192021222324252627
  1. package init_serve
  2. import (
  3. _ "eta_gn/eta_bridge/docs"
  4. "eta_gn/eta_bridge/global"
  5. "eta_gn/eta_bridge/middleware"
  6. "eta_gn/eta_bridge/routers"
  7. "github.com/gin-gonic/gin"
  8. )
  9. // InitRouter 初始化路由
  10. func InitRouter() (r *gin.Engine) {
  11. gin.SetMode(global.CONFIG.Serve.RunMode)
  12. r = gin.Default()
  13. r.Use(middleware.Cors())
  14. r.Use(middleware.Recover())
  15. common := middleware.Common{}
  16. r.Use(common.RequestLog)
  17. rBase := r.Group("api/")
  18. routers.InitAuth(rBase)
  19. routers.InitIndexData(rBase)
  20. routers.InitGn(rBase)
  21. return
  22. }