package router
|
|
import (
|
v1 "apsClient/api/v1"
|
"apsClient/conf"
|
_ "apsClient/docs"
|
"github.com/gin-contrib/cors"
|
"github.com/gin-gonic/gin"
|
swaggerFiles "github.com/swaggo/files"
|
ginSwagger "github.com/swaggo/gin-swagger"
|
"net/http"
|
)
|
|
func InitRouter() *gin.Engine {
|
gin.SetMode(gin.ReleaseMode)
|
|
Router := gin.Default()
|
Router.Use(gin.Recovery())
|
if conf.Conf.System.Env == "develop" {
|
Router.Use(gin.Logger())
|
}
|
Router.Use(cors.Default())
|
Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
|
PublicGroup := Router.Group("api")
|
{
|
// 健康监测
|
PublicGroup.GET("/health", func(c *gin.Context) {
|
c.JSON(http.StatusOK, "ok")
|
})
|
}
|
|
v1Group := Router.Group("v1")
|
|
// 接收通知
|
noticeApi := new(v1.NoticeApi)
|
noticeGroup := v1Group.Group("notice")
|
{
|
noticeGroup.POST("task/start", noticeApi.TaskStart) // 任务开启通知
|
}
|
|
return Router
|
}
|