Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs to add URL prefix to pprof middleware #294

Merged
merged 2 commits into from
Nov 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion api/middleware/pprof.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ After you initiate your Fiber app, you can use the following possibilities:
app.Use(pprof.New())
```

In systems where you have multiple ingress endpoints, it is common to add a URL prefix, like so:

```go
// Default middleware
app.Use(pprof.New(pprof.Config{Prefix: "/endpoint-prefix"}))
```

This prefix will be added to the default path of "/debug/pprof/", for a resulting URL of:
"/endpoint-prefix/debug/pprof/".

## Config

```go
Expand All @@ -38,6 +48,13 @@ type Config struct {
//
// Optional. Default: nil
Next func(c *fiber.Ctx) bool

// Prefix defines a URL prefix added before "/debug/pprof".
// Note that it should start with (but not end with) a slash.
// Example: "/federated-fiber"
//
// Optional. Default: ""
Prefix string
}
```

Expand All @@ -47,4 +64,4 @@ type Config struct {
var ConfigDefault = Config{
Next: nil,
}
```
```