Path: redb-route/redb.Route.Grpc/GrpcHeaderFilterStrategy.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Grpc/GrpcHeaderFilterStrategy.cs
----
using redb.Route.Abstractions;
namespace redb.Route.Grpc;
///
/// The default of the gRPC component. An endpoint's
/// headerFilterStrategy=#name replaces it; derive from it to add to it.
///
/// A producer sends every exchange header but the component's own redbGrpc.* and null values as call metadata
/// and, in envelope mode, as envelope headers; a consumer's reply envelope carries the same. A consumer brings every
/// request metadata entry and envelope header in, and a producer every reply envelope header.
///
///
/// Whatever the strategy: HTTP/2 pseudo-headers and grpc-* entries are the protocol's own; a caller's header
/// with a transport-reserved prefix (redbGrpc., redbHttp....) is dropped on the way in unless
/// allowClientReservedHeaders=true; a metadata key gRPC cannot express is not sent; the consumer's
/// redbGrpc.* call metadata, the envelope's Content-Type and the redbGrpc.Trailer.* trailers are
/// set by the component; trace context is written by the telemetry layer.
///
///
public class GrpcHeaderFilterStrategy : IHeaderFilterStrategy
{
/// The default strategy of a gRPC endpoint.
public static GrpcHeaderFilterStrategy Default { get; } = new();
///
public virtual bool FilterOutgoing(string name, object? value, IExchange exchange)
=> value is null || GrpcHeaders.IsRedbHeader(name);
///
public virtual bool FilterIncoming(string name, object? value, IExchange exchange) => false;
}