Help us shape the future of Go! Take the 2026 Go Developer Survey

requestid

package
v0.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 3 Imported by: 8

Documentation

Overview

Package requestid generates, validates and carries request IDs in a context.Context, so HTTP middleware, logging, audit and jobs share one correlation value (ADR-0030).

Stability: stable (ADR-0015, ADR-0054).

Index

Constants

View Source
const Header = "X-Request-ID"

Header is the HTTP header carrying the request ID.

View Source
const MaxLength = 128

MaxLength is the longest accepted incoming request ID.

Variables

This section is empty.

Functions

func From

func From(ctx context.Context) string

From returns the request ID in ctx, or "".

func New

func New() string

New returns a random request ID such as "req_9f86d081884c7d65".

func Valid

func Valid(id string) bool

Valid reports whether id is safe to accept from a client: 1 to MaxLength characters of letters, digits, '-', '_', '.' or ':'. This keeps untrusted IDs from injecting content into logs.

func With

func With(ctx context.Context, id string) context.Context

With returns a copy of ctx carrying id.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL