feat: 合并代码
This commit is contained in:
30
src/app.go
30
src/app.go
@@ -1,6 +1,7 @@
|
||||
package src
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
|
||||
"ems.agt/src/framework/config"
|
||||
@@ -10,11 +11,16 @@ import (
|
||||
"ems.agt/src/modules/common"
|
||||
"ems.agt/src/modules/crontask"
|
||||
"ems.agt/src/modules/monitor"
|
||||
netelement "ems.agt/src/modules/net_element"
|
||||
"ems.agt/src/modules/system"
|
||||
"ems.agt/src/modules/trace"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
//go:embed assets/*
|
||||
var assetsDir embed.FS
|
||||
|
||||
// 路由函数句柄,交给由 http.ListenAndServe(addr, router)
|
||||
func AppEngine() *gin.Engine {
|
||||
app := initAppEngine()
|
||||
@@ -25,12 +31,11 @@ func AppEngine() *gin.Engine {
|
||||
// 初始模块路由
|
||||
initModulesRoute(app)
|
||||
|
||||
// 设置程序内全局资源访问
|
||||
config.SetAssetsDirFS(assetsDir)
|
||||
|
||||
// 读取服务配置
|
||||
app.ForwardedByClientIP = config.Get("server.proxy").(bool)
|
||||
addr := fmt.Sprintf(":%d", config.Get("server.port").(int))
|
||||
|
||||
// 启动服务
|
||||
fmt.Printf("\nopen http://localhost%s \n\n", addr)
|
||||
return app
|
||||
}
|
||||
|
||||
@@ -43,13 +48,7 @@ func AppEngine() *gin.Engine {
|
||||
// }
|
||||
// }
|
||||
func RunServer() error {
|
||||
app := initAppEngine()
|
||||
|
||||
// 初始全局默认
|
||||
initDefeat(app)
|
||||
|
||||
// 初始模块路由
|
||||
initModulesRoute(app)
|
||||
app := AppEngine()
|
||||
|
||||
// 读取服务配置
|
||||
app.ForwardedByClientIP = config.Get("server.proxy").(bool)
|
||||
@@ -113,9 +112,16 @@ func initDefeat(app *gin.Engine) {
|
||||
|
||||
// 初始模块路由
|
||||
func initModulesRoute(app *gin.Engine) {
|
||||
|
||||
// 通用模块
|
||||
common.Setup(app)
|
||||
// 监控模块
|
||||
monitor.Setup(app)
|
||||
// 系统模块
|
||||
system.Setup(app)
|
||||
// 网元模块
|
||||
netelement.Setup(app)
|
||||
// 跟踪模块
|
||||
trace.Setup(app)
|
||||
// 调度任务模块--暂无接口
|
||||
crontask.Setup(app)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user