12345678910111213141516171819202122232425262728293031 |
- package init_serve
- import (
- "github.com/gin-gonic/gin"
- _ "hongze/hongtao3_watch/docs"
- "hongze/hongtao3_watch/global"
- "hongze/hongtao3_watch/middleware"
- "hongze/hongtao3_watch/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/")
- //系统相关路由
- indexGroup := rBase.Group("index/")
- routers.InitIndex(indexGroup)
- return
- }
|