middleware

package
v1.0.0-alpha.24 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOperationIdToContext

func AddOperationIdToContext() oasapi.Middleware

func Chain

func Chain(h http.Handler, mws ...func(http.Handler) http.Handler) http.Handler

Chain applies mws to h so the first listed runs outermost — first to see the request, last to see the response — matching the top-to-bottom reading order of the equivalent nested wrapping.

func GetOperationIDContext

func GetOperationIDContext(ctx context.Context) (string, bool)

func GetRequestIDContext

func GetRequestIDContext(ctx context.Context) (string, bool)

func UserAgentFromContext

func UserAgentFromContext(ctx context.Context) (*domain.UserAgent, bool)

UserAgentFromContext returns the device context injected by WithUserAgentMiddleware.

func WithLogging

func WithLogging(next http.Handler) http.Handler

func WithOperationIDContext

func WithOperationIDContext(ctx context.Context, operationID string) context.Context

WithOperationIDContext adds the given operation ID to the given context. The value is wrapped in struct so that it can be set downstream and retrieved upstream in the callstack. If a wrapper already exists in the context, its value is set instead of creating a new wrapper.

func WithRequestContext

func WithRequestContext(ctx context.Context, rc RequestContext) context.Context

func WithRequestContextMiddleware

func WithRequestContextMiddleware(generator RequestIDGenerator, next http.Handler) http.Handler

WithRequestContextMiddleware mints request_id, stores RequestContext, and echoes X-Request-Id.

func WithRequestIDContext

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

func WithUserAgentMiddleware

func WithUserAgentMiddleware(next http.Handler) http.Handler

WithUserAgentMiddleware makes the request's User-Agent header and client IP available to handlers via UserAgentFromContext.

Types

type RequestContext

type RequestContext struct {
	RequestID   string
	SessionID   string
	FlowID      string
	Fingerprint string
}

RequestContext carries server-authoritative correlation fields for Path A/B events.

func GetRequestContext

func GetRequestContext(ctx context.Context) (RequestContext, bool)

type RequestIDGenerator

type RequestIDGenerator interface {
	New(prefix string) (string, error)
}

RequestIDGenerator mints correlation ids for HTTP requests (not resource PKs).

Jump to

Keyboard shortcuts

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