1 Star 0 Fork 0

hh/iris

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
pprof.go 1.72 KB
一键复制 编辑 原始数据 按行查看 历史
// Package pprof provides native pprof support via middleware. See _examples/miscellaneous/pprof
package pprof
import (
"net/http/pprof"
"strings"
"github.com/kataras/iris/context"
"github.com/kataras/iris/core/handlerconv"
)
// New returns a new pprof (profile, cmdline, symbol, goroutine, heap, threadcreate, debug/block) Middleware.
// Note: Route MUST have the last named parameter wildcard named '{action:path}'
func New() context.Handler {
indexHandler := handlerconv.FromStd(pprof.Index)
cmdlineHandler := handlerconv.FromStd(pprof.Cmdline)
profileHandler := handlerconv.FromStd(pprof.Profile)
symbolHandler := handlerconv.FromStd(pprof.Symbol)
goroutineHandler := handlerconv.FromStd(pprof.Handler("goroutine"))
heapHandler := handlerconv.FromStd(pprof.Handler("heap"))
threadcreateHandler := handlerconv.FromStd(pprof.Handler("threadcreate"))
debugBlockHandler := handlerconv.FromStd(pprof.Handler("block"))
return func(ctx context.Context) {
ctx.ContentType("text/html")
actionPathParameter := ctx.Values().GetString("action")
if len(actionPathParameter) > 1 {
if strings.Contains(actionPathParameter, "cmdline") {
cmdlineHandler((ctx))
} else if strings.Contains(actionPathParameter, "profile") {
profileHandler(ctx)
} else if strings.Contains(actionPathParameter, "symbol") {
symbolHandler(ctx)
} else if strings.Contains(actionPathParameter, "goroutine") {
goroutineHandler(ctx)
} else if strings.Contains(actionPathParameter, "heap") {
heapHandler(ctx)
} else if strings.Contains(actionPathParameter, "threadcreate") {
threadcreateHandler(ctx)
} else if strings.Contains(actionPathParameter, "debug/block") {
debugBlockHandler(ctx)
}
} else {
indexHandler(ctx)
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/w1229748769/iris.git
git@gitee.com:w1229748769/iris.git
w1229748769
iris
iris
v8.2.1

搜索帮助

0d507c66 1850385 C8b1a773 1850385