Adds an indentifier to the response using the X-Request-ID header
go get -u github.com/gofiber/fiber
go get -u github.com/gofiber/requestid
requestid.New(config ...requestid.Config) func(*fiber.Ctx)| Property | Type | Description | Default |
|---|---|---|---|
| Skip | func(*fiber.Ctx) bool |
A function to skip the middleware | nil |
| Generator | func() string |
A function to generate an ID.e | return uuid.New().String() |
package main
import (
"github.com/gofiber/fiber"
"github.com/gofiber/requestid"
)
func main() {
app := fiber.New()
app.Use(requestid.New())
app.Get("/", func(c *fiber.Ctx) {
c.Send(requestid.Get(c))
})
app.Listen(3000)
}curl -I http://localhost:3000