router.go 873 B

123456789101112131415161718192021222324252627282930313233343536
  1. package initialize
  2. import (
  3. "mtp20access/global"
  4. "mtp20access/middleware"
  5. "github.com/gin-gonic/gin"
  6. ginSwagger "github.com/swaggo/gin-swagger"
  7. "github.com/swaggo/gin-swagger/swaggerFiles"
  8. )
  9. func Routers() *gin.Engine {
  10. Router := gin.Default()
  11. // 跨域,如需跨域可以打开下面的注释
  12. // Router.Use(middleware.Cors()) // 直接放行全部跨域请求
  13. // Router.Use(middleware.CorsByRules()) // 按照配置的规则放行跨域请求
  14. //global.GVA_LOG.Info("use middleware cors")
  15. // 开发测试模式
  16. if global.M2A_CONFIG.System.Env == "develop" {
  17. Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
  18. global.M2A_LOG.Info("register swagger handler")
  19. }
  20. // 非鉴权组
  21. // PublicGroup := Router.Group("")
  22. // 鉴权组
  23. PrivateGroup := Router.Group("")
  24. PrivateGroup.Use(middleware.JWTAuth())
  25. {
  26. }
  27. return Router
  28. }