package init_serve import ( "github.com/gin-gonic/gin" _ "hongze/hongze_google_api/docs" "hongze/hongze_google_api/global" "hongze/hongze_google_api/middleware" "hongze/hongze_google_api/routers" ) // InitRouter 初始化路由 func InitRouter() (r *gin.Engine) { //设置 gin.SetMode(global.CONFIG.Serve.RunMode) // 1.创建路由 r = gin.Default() r.Use(middleware.Cors()) //r.Use(gin.Recovery()) r.Use(middleware.Recover()) // 公共的中间件 r.Use(middleware.Common()) //swagger界面访问地址 http://localhost:8390/swagger/index.html // r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) rBase := r.Group("api/") routers.InitTranslate(rBase) return }