github.com/gofiber/fiber/v2@v2.47.0/docs/api/middleware/pprof.md (about)

     1  ---
     2  id: pprof
     3  title: Pprof
     4  ---
     5  
     6  Pprof middleware for [Fiber](https://github.com/gofiber/fiber) that serves via its HTTP server runtime profiling data in the format expected by the pprof visualization tool. The package is typically only imported for the side effect of registering its HTTP handlers. The handled paths all begin with /debug/pprof/.
     7  
     8  ## Signatures
     9  
    10  ```go
    11  func New() fiber.Handler
    12  ```
    13  
    14  ## Examples
    15  
    16  Import the middleware package that is part of the Fiber web framework
    17  
    18  ```go
    19  import (
    20    "github.com/gofiber/fiber/v2"
    21    "github.com/gofiber/fiber/v2/middleware/pprof"
    22  )
    23  ```
    24  
    25  After you initiate your Fiber app, you can use the following possibilities:
    26  
    27  ```go
    28  // Initialize default config
    29  app.Use(pprof.New())
    30  
    31  // Or extend your config for customization
    32  
    33  // For example, in systems where you have multiple ingress endpoints, it is common to add a URL prefix, like so:
    34  app.Use(pprof.New(pprof.Config{Prefix: "/endpoint-prefix"}))
    35  
    36  // This prefix will be added to the default path of "/debug/pprof/", for a resulting URL of: "/endpoint-prefix/debug/pprof/".
    37  ```
    38  
    39  ## Config
    40  
    41  ```go
    42  // Config defines the config for middleware.
    43  type Config struct {
    44      // Next defines a function to skip this middleware when returned true.
    45      //
    46      // Optional. Default: nil
    47      Next func(c *fiber.Ctx) bool
    48  
    49      // Prefix defines a URL prefix added before "/debug/pprof".
    50      // Note that it should start with (but not end with) a slash.
    51      // Example: "/federated-fiber"
    52      //
    53      // Optional. Default: ""
    54      Prefix string
    55  }
    56  ```
    57  
    58  ## Default Config
    59  
    60  ```go
    61  var ConfigDefault = Config{
    62      Next: nil,
    63  }
    64  ```