Skip to main content

Module metadata

Module metadata 

Source
Expand description

§Metadata

§Purpose

Utilities for translating HTTP headers into gRPC metadata. This allows context such as authentication tokens, tracing IDs, and custom headers to be propagated to the upstream gRPC service.

§Scope

This module defines:

  • forward_metadata: Propagates HTTP headers to tonic::metadata::MetadataMap.
  • grpc_timeout: Parses grpc-timeout headers into Duration.

§Position in the Architecture

Called by generated code before making the gRPC request. It populates the tonic::Request metadata from the incoming http::Request headers.

§Design Constraints

  • Filtering: Certain headers (e.g., Content-Type, Host) are filtered out to prevent interference with the gRPC transport.
  • Security: Only forwards headers that match allowed prefixes or are explicitly permitted to prevent header injection attacks.

Structs§

MetadataForwardingConfig
Configuration for metadata forwarding security.

Functions§

forward_metadata
Propagates HTTP headers from the incoming request to the gRPC metadata map.
grpc_timeout
Parses the grpc-timeout header value into a Duration.