12345678910111213141516171819202122232425262728293031 |
- package init_serve
- import (
- "github.com/gin-gonic/gin"
- _ "hongze/hongze_yb_en_api/docs"
- "hongze/hongze_yb_en_api/global"
- "hongze/hongze_yb_en_api/middleware"
- "hongze/hongze_yb_en_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.InitAuth(rBase)
- routers.InitReport(rBase)
- routers.InitPublic(rBase)
- return
- }
|