feat: add pprof function

This commit is contained in:
engigu
2026-03-10 17:02:25 +08:00
parent 03ee39fccf
commit fdfb8fc06a
4 changed files with 25 additions and 4 deletions
+6
View File
@@ -7,6 +7,7 @@ import (
"github.com/engigu/baihu-panel/internal/middleware"
"github.com/engigu/baihu-panel/internal/services"
"github.com/gin-contrib/pprof"
"github.com/gin-gonic/gin"
)
@@ -38,6 +39,11 @@ func Setup(c *Controllers) *gin.Engine {
cfg := services.GetConfig()
urlPrefix := strings.TrimSuffix(cfg.Server.URLPrefix, "/")
// 按需绑定 Pprof 调试路由
if cfg.Server.PprofEnabled {
pprof.Register(router)
}
// 创建一个路由组,如果有前缀则使用前缀,否则使用根路径
var root *gin.RouterGroup
if urlPrefix != "" {