package initialize import ( "mtp20access/api/console" "mtp20access/global" "mtp20access/middleware" "mtp20access/router" _ "mtp20access/docs" "github.com/gin-gonic/gin" ginSwagger "github.com/swaggo/gin-swagger" "github.com/swaggo/gin-swagger/swaggerFiles" ) func Routers() *gin.Engine { Router := gin.Default() // 跨域,如需跨域可以打开下面的注释 // Router.Use(middleware.Cors()) // 直接放行全部跨域请求 // Router.Use(middleware.CorsByRules()) // 按照配置的规则放行跨域请求 //global.GVA_LOG.Info("use middleware cors") // 开发测试模式 if global.M2A_CONFIG.System.Env == "develop" { Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) global.M2A_LOG.Info("register swagger handler") Router.GET("/debug/console", console.Console) Router.GET("/debug/update", console.MakeUpdateScript) } // 非鉴权组 publicGroup := Router.Group("") { router.InitAccountPublicRouter(publicGroup) } // 鉴权组 privateGroup := Router.Group("") privateGroup.Use(middleware.JWTAuth()) { router.InitMQPrivateRouter(privateGroup) } return Router }