pprof

package
v0.0.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 7 Imported by: 0

README

pprof Middleware

What it does

Registers protected Go profiling endpoints for CPU, heap, goroutine, mutex, block, and trace diagnostics.

How to implement

package main

import (
	"github.com/oarkflow/fh"
	"github.com/oarkflow/fh/mw/pprof"
)

func main() {
	app := fh.New()
	pprof.Enable(app, pprof.Config{
		Prefix: "/_fh/debug/pprof",
		Auth: pprof.StaticToken("X-Admin-Token", "change-me"),
	})

	app.Get("/", func(c fh.Ctx) error { return c.Status(fh.StatusOK).SendString("ok") })
}

Impact

No request-path overhead except for the registered debug endpoints. Profiling itself can add overhead while active.

Ordering guidance

Register separately from public routes. Keep behind admin authentication and private networking.

Production considerations

Never expose pprof publicly. Use temporary access during incidents and audit access.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enable

func Enable(app *fh.App, cfg Config) *fh.App

Types

type AuthFunc

type AuthFunc func(fh.Ctx) bool

func StaticToken

func StaticToken(header, token string) AuthFunc

type Config

type Config struct {
	Prefix string
	Auth   AuthFunc
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL