Skip to content

Commit

Permalink
Merge pull request #294 from gmlewis/i2194-add-url-prefix-to-pprof
Browse files Browse the repository at this point in the history
Update docs to add URL prefix to pprof middleware
  • Loading branch information
ReneWerner87 committed Nov 18, 2022
2 parents ee3d598 + 4800d27 commit 55e0463
Showing 1 changed file with 18 additions and 1 deletion.
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,
}
```
```

0 comments on commit 55e0463

Please sign in to comment.