Documentation
¶
Overview ¶
Package pprof registers Go pprof handlers on an HTTP router.
RegisterRoutes wires profiling handlers only; it does not add authentication, authorization, or network restrictions. Prefer RegisterAdminRoutes for new admin mounts so an explicit wrapper is required at construction time.
Purpose: See the package summary above. Import: `github.com/aatuh/api-toolkit/v4/endpoints/pprof`. Example: See docs/api-reference.md for package example links and docs/cookbook.md for task recipes. Errors: Constructors, parsers, and handlers return or write documented errors according to their signatures; packages with plain data types do not add hidden error channels. Concurrency: Treat configured middleware and helpers as immutable after construction; request and response values remain request-scoped unless a type documents stronger guarantees. Stability: Stable core API under VERSIONING.md and scripts/apicheck.sh. When not to use: Prefer net/http, application-owned types, or narrower helpers when this package contract is not needed.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterAdminRoutes ¶
RegisterAdminRoutes wires pprof handlers behind an explicit authorization or internal-network wrapper. Passing nil fails closed so admin-only mounts cannot accidentally expose pprof without policy.
Example ¶
package main
import (
"fmt"
"net/http"
pprofendpoint "github.com/aatuh/api-toolkit/v4/endpoints/pprof"
)
type examplePprofRouter struct {
patterns []string
}
func (r *examplePprofRouter) Get(pattern string, _ http.HandlerFunc) {
r.patterns = append(r.patterns, pattern)
}
func main() {
router := &examplePprofRouter{}
requireAdmin := func(next http.Handler) http.Handler { return next }
if err := pprofendpoint.RegisterAdminRoutes(router, requireAdmin); err != nil {
panic(err)
}
fmt.Println(len(router.patterns))
}
Output: 5
func RegisterRoutes ¶
func RegisterRoutes(r Router)
RegisterRoutes wires the default pprof handlers on the provided router. Deprecated: prefer RegisterAdminRoutes for new admin mounts so an explicit authorization or internal-network wrapper is required.
Types ¶
type Router ¶
type Router interface {
Get(pattern string, h http.HandlerFunc)
}
Router defines the minimal GET registration contract needed for pprof routes.