requestid

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) string

FromContext extracts the request ID from ctx.

func HTTPMiddleware

func HTTPMiddleware(next http.Handler) http.Handler

HTTPMiddleware injects or propagates X-Request-ID for HTTP handlers. If the incoming request already carries the header, it is reused; otherwise a new UUID is generated. The ID is set on the response header and injected into the request context.

func NewContext

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

NewContext returns a copy of ctx with the given request ID attached.

func StreamServerInterceptor

func StreamServerInterceptor(srv any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error

StreamServerInterceptor propagates or generates x-request-id for gRPC streaming calls.

func UnaryServerInterceptor

func UnaryServerInterceptor(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error)

UnaryServerInterceptor propagates or generates x-request-id for gRPC unary calls.

Types

This section is empty.

Jump to

Keyboard shortcuts

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