ctxinject

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 5 Imported by: 0

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

View Source
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

func WithReplyHeaders(requestID, traceID, tenantID string) Option

WithReplyHeaders configures response header names used to echo injected values. Pass an empty name to disable echoing that value.

func WithRequestIDHeaders

func WithRequestIDHeaders(headers ...string) Option

WithRequestIDHeaders configures accepted request-id header names.

func WithTenantHeaders

func WithTenantHeaders(headers ...string) Option

WithTenantHeaders configures accepted tenant-id header names.

func WithTraceIDHeaders

func WithTraceIDHeaders(headers ...string) Option

WithTraceIDHeaders configures accepted trace-id header names.

Jump to

Keyboard shortcuts

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