Categorygithub.com/gofiber/requestid
repositorypackage
0.1.1
Repository: https://github.com/gofiber/requestid.git
Documentation: pkg.go.dev

# README

Request ID

Release Discord Test Security Linter

Adds an indentifier to the response using the X-Request-ID header

Install

go get -u github.com/gofiber/fiber
go get -u github.com/gofiber/requestid

Signature

requestid.New(config ...requestid.Config) func(*fiber.Ctx)

Config

PropertyTypeDescriptionDefault
Skipfunc(*fiber.Ctx) boolA function to skip the middlewarenil
Generator func() stringA function to generate an ID.ereturn uuid.New().String()

Example

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)
}

Test

curl -I http://localhost:3000