requestidbridge

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package requestidbridge integrates explicitly with request ID middleware such as http-middleware/requestid without importing hidden context keys. Adopt validates the selected lookup's request ID under explicit trust and derives a context. It performs no middleware installation or authentication; lookup lifetime, concurrency, blocking and panic behavior remain caller-owned.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidLookup reports a missing lookup or malformed returned value.
	ErrInvalidLookup = errors.New("request ID bridge: invalid lookup")
	// ErrUntrusted reports a source that was not explicitly trusted.
	ErrUntrusted = errors.New("request ID bridge: source is not trusted")
	// ErrMissing reports an absent middleware request ID.
	ErrMissing = errors.New("request ID bridge: request ID is missing")
	// ErrOverwrite reports an attempt to replace an existing request ID.
	ErrOverwrite = errors.New("request ID bridge: request ID overwrite")
)

Functions

func Adopt

func Adopt(ctx context.Context, values correlation.Values, lookup Lookup, options Options) (context.Context, correlation.Values, error)

Adopt validates a middleware request ID, refuses overwrite, and returns a derived context containing the complete supplied Values with that request ID. Existing parent-context Values are not merged or consulted for overwrite. Errors return the original ctx and zero Values. Nil ctx/lookup is invalid; other supplied identity fields are neither validated nor promoted to trust.

Types

type Lookup

type Lookup func(context.Context) (string, bool)

Lookup matches a bound call to requestid.FromContext. The application keeps ownership of which middleware package and Kind it selects. The callback is invoked synchronously after trust/overwrite checks, without panic recovery.

type Options

type Options struct {
	// Policy validates the looked-up request ID only; other supplied Values
	// fields are preserved without validation.
	Policy correlation.Policy
	// Trusted must explicitly accept the lookup's authenticated boundary.
	// False fails before calling lookup; the bridge does not verify trust.
	Trusted bool
}

Options require explicit trust for the middleware-owned context value.

Jump to

Keyboard shortcuts

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