ginpprof

package module
v0.0.0-...-6416bba Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 3 Imported by: 146

README

ginpprof

Go Reference

A wrapper for gin to mount net/http/pprof routes quickly.

Why this project

ginpprof was created before gin-contrib/pprof, and many existing services still rely on it. This repository is maintained to keep those users on a stable and lightweight API.

Install

go get github.com/DeanThompson/ginpprof@latest

Usage

package main

import (
	"github.com/gin-gonic/gin"

	"github.com/DeanThompson/ginpprof"
)

func main() {
	router := gin.Default()

	router.GET("/ping", func(c *gin.Context) {
		c.String(200, "pong")
	})

	// Mount default pprof routes under /debug/pprof
	ginpprof.Wrap(router)

	// Or mount via group:
	// group := router.Group("/debug/pprof")
	// ginpprof.WrapGroup(group)

	router.Run(":8080")
}
Registered routes
  • GET /debug/pprof/
  • GET /debug/pprof/heap
  • GET /debug/pprof/goroutine
  • GET /debug/pprof/allocs
  • GET /debug/pprof/block
  • GET /debug/pprof/threadcreate
  • GET /debug/pprof/cmdline
  • GET /debug/pprof/profile
  • GET /debug/pprof/symbol
  • POST /debug/pprof/symbol
  • GET /debug/pprof/trace
  • GET /debug/pprof/mutex

Security notes

pprof endpoints expose runtime internals. For production:

  • protect routes with auth middleware,
  • restrict by network/IP,
  • or expose only in internal environments.

Development

go test ./...

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Wrapper = Wrap

Wrapper make sure we are backward compatible

Functions

func AllocsHandler

func AllocsHandler() gin.HandlerFunc

AllocsHandler will pass the call from /debug/pprof/allocs to pprof

func BlockHandler

func BlockHandler() gin.HandlerFunc

BlockHandler will pass the call from /debug/pprof/block to pprof

func CmdlineHandler

func CmdlineHandler() gin.HandlerFunc

CmdlineHandler will pass the call from /debug/pprof/cmdline to pprof

func GoroutineHandler

func GoroutineHandler() gin.HandlerFunc

GoroutineHandler will pass the call from /debug/pprof/goroutine to pprof

func HeapHandler

func HeapHandler() gin.HandlerFunc

HeapHandler will pass the call from /debug/pprof/heap to pprof

func IndexHandler

func IndexHandler() gin.HandlerFunc

IndexHandler will pass the call from /debug/pprof to pprof

func MutexHandler

func MutexHandler() gin.HandlerFunc

MutexHandler will pass the call from /debug/pprof/mutex to pprof

func ProfileHandler

func ProfileHandler() gin.HandlerFunc

ProfileHandler will pass the call from /debug/pprof/profile to pprof

func SymbolHandler

func SymbolHandler() gin.HandlerFunc

SymbolHandler will pass the call from /debug/pprof/symbol to pprof

func ThreadCreateHandler

func ThreadCreateHandler() gin.HandlerFunc

ThreadCreateHandler will pass the call from /debug/pprof/threadcreate to pprof

func TraceHandler

func TraceHandler() gin.HandlerFunc

TraceHandler will pass the call from /debug/pprof/trace to pprof

func Wrap

func Wrap(router *gin.Engine)

Wrap adds several routes from package `net/http/pprof` to *gin.Engine object

func WrapGroup

func WrapGroup(router *gin.RouterGroup)

WrapGroup adds several routes from package `net/http/pprof` to *gin.RouterGroup object

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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