2024-07-23 14:48:37 +08:00
|
|
|
package router
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/1Panel-dev/1Panel/agent/i18n"
|
2024-07-31 18:29:41 +08:00
|
|
|
"github.com/1Panel-dev/1Panel/agent/middleware"
|
2024-07-23 14:48:37 +08:00
|
|
|
rou "github.com/1Panel-dev/1Panel/agent/router"
|
|
|
|
"github.com/gin-contrib/gzip"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
Router *gin.Engine
|
|
|
|
)
|
|
|
|
|
|
|
|
func Routers() *gin.Engine {
|
|
|
|
Router = gin.Default()
|
|
|
|
Router.Use(i18n.UseI18n())
|
|
|
|
|
|
|
|
PublicGroup := Router.Group("")
|
|
|
|
{
|
|
|
|
PublicGroup.GET("/health", func(c *gin.Context) {
|
|
|
|
c.JSON(200, "ok")
|
|
|
|
})
|
|
|
|
PublicGroup.Use(gzip.Gzip(gzip.DefaultCompression))
|
2024-07-29 14:13:47 +08:00
|
|
|
PublicGroup.Static("/api/v1/images", "./uploads")
|
2024-07-23 14:48:37 +08:00
|
|
|
}
|
2024-07-25 14:43:41 +08:00
|
|
|
PrivateGroup := Router.Group("/api/v2")
|
2024-07-31 18:29:41 +08:00
|
|
|
PrivateGroup.Use(middleware.Certificate())
|
2024-07-23 14:48:37 +08:00
|
|
|
for _, router := range rou.RouterGroupApp {
|
|
|
|
router.InitRouter(PrivateGroup)
|
|
|
|
}
|
|
|
|
|
|
|
|
return Router
|
|
|
|
}
|