Documentation
¶
Overview ¶
Package ctxinject injects transport metadata into Kernel request contexts.
It is intended to be one of the first server-side middlewares in both HTTP and gRPC stacks. Downstream middleware and business code can then rely on contextx helpers instead of re-parsing headers at every boundary.
Index ¶
Constants ¶
const ( HeaderRequestID = "X-Request-ID" HeaderTraceID = "X-Trace-ID" HeaderTenantID = "X-Tenant-ID" )
Variables ¶
This section is empty.
Functions ¶
func Server ¶
func Server(opts ...Option) middleware.Middleware
Server returns a middleware that extracts request_id, trace_id and tenant_id from transport headers into contextx. It works for HTTP and gRPC because it only depends on transportx.Transporter.
Types ¶
type Option ¶
type Option func(*options)
Option configures Server.
func WithReplyHeaders ¶
WithReplyHeaders configures response header names used to echo injected values. Pass an empty name to disable echoing that value.
func WithRequestIDHeaders ¶
WithRequestIDHeaders configures accepted request-id header names.
func WithTenantHeaders ¶
WithTenantHeaders configures accepted tenant-id header names.
func WithTraceIDHeaders ¶
WithTraceIDHeaders configures accepted trace-id header names.