2022-08-16 23:30:23 +08:00
|
|
|
package router
|
|
|
|
|
|
|
|
import (
|
2022-08-17 19:02:48 +08:00
|
|
|
"html/template"
|
|
|
|
|
2022-09-15 17:15:03 +08:00
|
|
|
v1 "github.com/1Panel-dev/1Panel/app/api/v1"
|
2022-08-16 23:30:23 +08:00
|
|
|
"github.com/1Panel-dev/1Panel/docs"
|
|
|
|
"github.com/1Panel-dev/1Panel/i18n"
|
|
|
|
"github.com/1Panel-dev/1Panel/middleware"
|
|
|
|
rou "github.com/1Panel-dev/1Panel/router"
|
|
|
|
ginI18n "github.com/gin-contrib/i18n"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
swaggerfiles "github.com/swaggo/files"
|
|
|
|
ginSwagger "github.com/swaggo/gin-swagger"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Routers() *gin.Engine {
|
|
|
|
Router := gin.Default()
|
|
|
|
Router.Use(middleware.CSRF())
|
|
|
|
Router.Use(middleware.LoadCsrfToken())
|
|
|
|
|
|
|
|
docs.SwaggerInfo.BasePath = "/api/v1"
|
2022-09-15 17:15:03 +08:00
|
|
|
|
2022-08-16 23:30:23 +08:00
|
|
|
Router.Use(i18n.GinI18nLocalize())
|
2022-09-15 17:15:03 +08:00
|
|
|
Router.GET("/api/v1/info", v1.ApiGroupApp.BaseApi.GetSafetyStatus)
|
|
|
|
Router.GET("/api/v1/:code", v1.ApiGroupApp.BaseApi.SafeEntrance)
|
|
|
|
Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
|
2022-08-16 23:30:23 +08:00
|
|
|
|
|
|
|
Router.SetFuncMap(template.FuncMap{
|
|
|
|
"Localize": ginI18n.GetMessage,
|
|
|
|
})
|
|
|
|
Router.Use(middleware.JwtAuth())
|
|
|
|
|
|
|
|
systemRouter := rou.RouterGroupApp
|
|
|
|
|
|
|
|
PublicGroup := Router.Group("")
|
|
|
|
{
|
|
|
|
PublicGroup.GET("/health", func(c *gin.Context) {
|
|
|
|
c.JSON(200, "ok")
|
|
|
|
})
|
|
|
|
}
|
2022-09-15 17:15:03 +08:00
|
|
|
|
2022-08-16 23:30:23 +08:00
|
|
|
PrivateGroup := Router.Group("/api/v1")
|
2022-09-15 17:15:03 +08:00
|
|
|
PrivateGroup.Use(middleware.SafetyAuth())
|
2022-08-16 23:30:23 +08:00
|
|
|
{
|
|
|
|
systemRouter.InitBaseRouter(PrivateGroup)
|
2022-08-18 18:54:21 +08:00
|
|
|
systemRouter.InitHostRouter(PrivateGroup)
|
2022-09-16 18:53:45 +08:00
|
|
|
systemRouter.InitBackupRouter(PrivateGroup)
|
2022-08-31 23:16:10 +08:00
|
|
|
systemRouter.InitGroupRouter(PrivateGroup)
|
|
|
|
systemRouter.InitCommandRouter(PrivateGroup)
|
2022-08-17 19:02:48 +08:00
|
|
|
systemRouter.InitTerminalRouter(PrivateGroup)
|
2022-09-08 11:39:14 +08:00
|
|
|
systemRouter.InitMonitorRouter(PrivateGroup)
|
2022-08-16 23:30:23 +08:00
|
|
|
systemRouter.InitOperationLogRouter(PrivateGroup)
|
2022-08-24 11:10:50 +08:00
|
|
|
systemRouter.InitFileRouter(PrivateGroup)
|
2022-09-20 19:12:48 +08:00
|
|
|
systemRouter.InitCronjobRouter(PrivateGroup)
|
2022-09-15 10:44:43 +08:00
|
|
|
systemRouter.InitSettingRouter(PrivateGroup)
|
2022-08-16 23:30:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return Router
|
|
|
|
}
|