fgprof

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 3 Imported by: 0

README


id: fgprof

Fgprof

Release Discord Test Security Linter

fgprof support for Fiber.

Note: Requires Go 1.19 and above

Install

This middleware supports Fiber v2.

Using fgprof to profiling your Fiber app.

go get -u github.com/gofiber/fiber/v2
go get -u github.com/gofiber/contrib/fgprof

Config

Property Type Description Default
Next func(c *fiber.Ctx) bool A function to skip this middleware when returned true. nil
Prefix string. Prefix defines a URL prefix added before "/debug/fgprof". Note that it should start with (but not end with) a slash. Example: "/federated-fiber" ""

Example

package main

import (
	"log"

	"github.com/gofiber/contrib/fgprof"
	"github.com/gofiber/fiber/v2"
)

func main() {
	app := fiber.New()
	app.Use(fgprof.New())
	app.Get("/", func(c *fiber.Ctx) error {
		return c.SendString("OK")
	})
	log.Fatal(app.Listen(":3000"))
}
go tool pprof -http=:8080 http://localhost:3000/debug/fgprof

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigDefault = Config{
	Next: nil,
}

ConfigDefault is the default config

Functions

func New

func New(conf ...Config) fiber.Handler

Types

type Config

type Config struct {
	// Next defines a function to skip this middleware when returned true.
	//
	// Optional. Default: nil
	Next func(c *fiber.Ctx) bool

	// Prefix is the path where the fprof endpoints will be mounted.
	// Default Path is "/debug/fgprof"
	//
	// Optional. Default: ""
	Prefix string
}

Jump to

Keyboard shortcuts

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