httpcorrelation

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package httpcorrelation explicitly propagates correlation metadata over HTTP. Middleware installation and proxy trust remain application owned.

Index

Constants

View Source
const (
	// CorrelationHeader carries the logical workflow identifier.
	CorrelationHeader = "X-Correlation-ID"
	// RequestHeader carries the current HTTP hop identifier.
	RequestHeader = "X-Request-ID"
	// CausationHeader carries the immediate parent identifier.
	CausationHeader = "X-Causation-ID"
)

Variables

View Source
var ErrInvalidOptions = errors.New("http correlation: invalid options")

ErrInvalidOptions reports invalid HTTP adapter configuration.

Functions

This section is empty.

Types

type InvalidPolicy

type InvalidPolicy uint8

InvalidPolicy controls malformed or ambiguous inbound metadata.

const (
	// ReplaceInvalid discards every inbound value and creates a fresh root.
	ReplaceInvalid InvalidPolicy = iota
	// RejectInvalid returns HTTP 400 before application code runs.
	RejectInvalid
)

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

Middleware owns explicit HTTP extraction, trust, context, and injection.

func New

func New(factory *correlation.Factory, options Options) (*Middleware, error)

New constructs an HTTP adapter without installing global middleware.

func (*Middleware) Inject

func (middleware *Middleware) Inject(request *http.Request, parent correlation.Values) (correlation.Values, error)

Inject creates and injects the next outbound HTTP hop.

func (*Middleware) Wrap

func (middleware *Middleware) Wrap(next http.Handler) http.Handler

Wrap creates one fresh request ID per HTTP request. Valid inbound metadata is preserved only when Trust explicitly accepts the immediate peer.

type Options

type Options struct {
	Policy  correlation.Policy
	Invalid InvalidPolicy
	Trust   func(*http.Request) bool
}

Options configure immutable HTTP propagation policy.

Directories

Path Synopsis
Package requestidbridge integrates explicitly with request ID middleware such as http-middleware/requestid without importing hidden context keys.
Package requestidbridge integrates explicitly with request ID middleware such as http-middleware/requestid without importing hidden context keys.

Jump to

Keyboard shortcuts

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