代码拉取完成,页面将自动刷新
// 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)
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。