Documentation
¶
Overview ¶
Package pprof provides native pprof support via middleware.
Its entry point is New(), which returns a *ProfilingRouter rather than a Handler: pprof is a set of sibling endpoints (heap, profile, trace, ...), so the value is registered as a party with app.Any("/debug/pprof/{action:path}", pprof.New()) and it dispatches on the sub-path itself.
Labels policy: Iris sets no pprof labels. If labels are ever added, they must carry route metadata only (route path, method), never request data — see the SECURITY WARNING on `New` for why.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ProfilingRouter ¶
type ProfilingRouter struct{}
ProfilingRouter is the pprof (profile, cmdline, symbol, goroutine, heap, threadcreate, debug/block) Router.
func New ¶
func New() *ProfilingRouter
New returns a new pprof (profile, cmdline, symbol, goroutine, heap, threadcreate, debug/block) Router.
SECURITY WARNING: these endpoints MUST NOT be reachable without authentication.
GET /debug/pprof/goroutine?debug=2
dumps every goroutine's stack - source paths, function names and often argument values, which is where session identifiers and tokens live. The heap profile discloses the same through allocation sites. Anyone who can reach the route gets a detailed picture of the running process.
Goroutine dumps also include the goroutines' pprof labels, and for go1.27 modules labels print in panic traceback headers too - bypassing the recovery middleware's header redaction. Never put request data in pprof labels.
Usage - always behind a guard:
import "github.com/kataras/iris/v14/middleware/pprof"
import "github.com/kataras/iris/v14/middleware/basicauth"
[...]
app := iris.New()
auth := basicauth.Default(map[string]string{"admin": os.Getenv("PPROF_PASSWORD")})
app.Router("/debug/pprof", pprof.New()).Use(auth)
or restrict it by address with the ipaccess middleware, or bind the profiling endpoints to a separate, internal-only listener.
func (*ProfilingRouter) Routing ¶
func (p *ProfilingRouter) Routing(r router.Router)
Routing registers the necessary routes for the pprof middleware. Implements the `router.Controller` interface.