metadata

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package metadata carries request-scoped transport-neutral fields.

Only the trace identifier is propagated automatically. Identity fields are populated after authentication and can be propagated explicitly by trusted service clients; this prevents unauthenticated headers from becoming an authority boundary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractGRPC

func ExtractGRPC(ctx context.Context, md grpcmetadata.MD) context.Context

ExtractGRPC extracts the trace ID from inbound gRPC metadata.

func ExtractHTTP

func ExtractHTTP(ctx context.Context, header http.Header) context.Context

ExtractHTTP extracts the trace ID from inbound HTTP headers. It does not extract user or tenant identity; authentication must establish those values separately.

func InjectGRPC

func InjectGRPC(ctx context.Context) context.Context

InjectGRPC adds metadata to an outgoing gRPC context.

func InjectHTTP

func InjectHTTP(ctx context.Context, header http.Header)

InjectHTTP adds the trace ID to an outgoing HTTP request.

func InjectIdentityGRPC

func InjectIdentityGRPC(ctx context.Context) context.Context

InjectIdentityGRPC adds authenticated identity metadata to an outgoing gRPC context. Call this only for trusted service-to-service calls.

func InjectIdentityHTTP

func InjectIdentityHTTP(ctx context.Context, header http.Header)

InjectIdentityHTTP adds authenticated identity metadata to an outgoing request. Call this only for trusted service-to-service calls.

func With

func With(ctx context.Context, values Values) context.Context

With returns a context containing normalized metadata values.

Types

type Values

type Values struct {
	TraceID     string
	UserID      int64
	TenantID    int64
	WorkspaceID int64
	ShopIDs     []int64
	Scopes      []string
}

Values contains request metadata safe for use by the application layer.

func From

func From(ctx context.Context) Values

From returns metadata stored in ctx. A zero value is returned for nil or contexts without metadata.

Jump to

Keyboard shortcuts

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