Documentation
¶
Index ¶
- Constants
- func FromContext(ctx context.Context) string
- func HTTPMiddleware(next http.Handler) http.Handler
- func NewContext(ctx context.Context, id string) context.Context
- func StreamServerInterceptor(srv any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, ...) error
- func UnaryServerInterceptor(ctx context.Context, req any, _ *grpc.UnaryServerInfo, ...) (any, error)
Constants ¶
View Source
const Header = "X-Request-ID"
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶
FromContext extracts the request ID from ctx.
func HTTPMiddleware ¶
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 ¶
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.
Click to show internal directories.
Click to hide internal directories.