42 lines
920 B
Go
42 lines
920 B
Go
package router
|
|
|
|
import (
|
|
"sun-panel/global"
|
|
// "sun-panel/router/admin"
|
|
"sun-panel/router/openness"
|
|
"sun-panel/router/panel"
|
|
"sun-panel/router/system"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// 初始化总路由
|
|
func InitRouters(addr string) error {
|
|
router := gin.Default()
|
|
rootRouter := router.Group("/")
|
|
routerGroup := rootRouter.Group("api")
|
|
|
|
// 管理员接口
|
|
|
|
// 接口
|
|
system.Init(routerGroup)
|
|
// admin.Init(routerGroup)
|
|
panel.Init(routerGroup)
|
|
openness.Init(routerGroup)
|
|
|
|
// WEB文件服务
|
|
{
|
|
webPath := "./web"
|
|
router.StaticFile("/", webPath+"/index.html")
|
|
router.StaticFile("/favicon.ico", webPath+"/favicon.ico")
|
|
router.StaticFile("/favicon.svg", webPath+"/favicon.svg")
|
|
router.Static("/assets", webPath+"/assets")
|
|
}
|
|
|
|
// 上传的文件
|
|
router.Static("/uploads", "./uploads")
|
|
|
|
global.Logger.Info("Sun-Panel is Started. Listening and serving HTTP on ", addr)
|
|
return router.Run(addr)
|
|
}
|