优化结构

This commit is contained in:
Yvan
2026-08-21 16:52:37 +08:00
parent e22301f8f6
commit ba1c73fa66
5 changed files with 33 additions and 23 deletions
-20
View File
@@ -6,7 +6,6 @@ import (
"net/http"
"os"
"path"
"sort"
"strings"
"time"
@@ -79,28 +78,9 @@ func NewGinEngineWithRuntime(runtime *conf.Runtime, access *service.AccessContro
}
httpx.Fail(c, "请求的接口不存在")
})
logRegisteredRoutes(engine, logger)
return engine
}
func logRegisteredRoutes(engine *gin.Engine, logger *slog.Logger) {
if logger == nil {
return
}
routes := append([]gin.RouteInfo(nil), engine.Routes()...)
sort.Slice(routes, func(i, j int) bool {
if routes[i].Path == routes[j].Path {
return routes[i].Method < routes[j].Method
}
return routes[i].Path < routes[j].Path
})
systemLogger := logger.With("mod", "system")
for _, route := range routes {
systemLogger.Info("router registered", "method", route.Method, "path", route.Path)
}
systemLogger.Info("router register success", "route_count", len(routes))
}
func NewGinServer(c *conf.Server, engine *gin.Engine) *kratoshttp.Server {
network, address := "tcp", ":8000"
if c != nil && c.Http != nil {