| 123456789101112131415161718192021222324252627282930313233343536 |
- package initialize
- import (
- "mtp20access/global"
- "mtp20access/middleware"
- "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")
- }
- // 非鉴权组
- // PublicGroup := Router.Group("")
- // 鉴权组
- PrivateGroup := Router.Group("")
- PrivateGroup.Use(middleware.JWTAuth())
- {
- }
- return Router
- }
|