Documentation ¶
Overview ¶
Package clientinfo provides gRPC interceptors for acquiring client information from inbound gRPC requests and making that information available via context keys.
Index ¶
- func StreamClientInterceptor(clientID string) grpc.StreamClientInterceptor
- func StreamServerInterceptor(fn Extractor) grpc.StreamServerInterceptor
- func ToContext(ctx context.Context, info ClientInfo) context.Context
- func UnaryClientInterceptor(clientID string) grpc.UnaryClientInterceptor
- func UnaryServerInterceptor(fn Extractor) grpc.UnaryServerInterceptor
- type ClientInfo
- type Extractor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StreamClientInterceptor ¶
func StreamClientInterceptor(clientID string) grpc.StreamClientInterceptor
StreamClientInterceptor returns a grpc.StreamClientInterceptor implementation that appends the client identifier to outgoing gRPC metadata under the X-Client-ID key.
func StreamServerInterceptor ¶
func StreamServerInterceptor(fn Extractor) grpc.StreamServerInterceptor
StreamServerInterceptor is a grpc.StreamServerInterceptor implementation that adds a ClientInfo to inbound contexts via the provided Extractor implementation.
func ToContext ¶
func ToContext(ctx context.Context, info ClientInfo) context.Context
ToContext adds the provided ClientInfo to the parent context, returning a new context. It can be retrieved from the context using FromContext.
func UnaryClientInterceptor ¶
func UnaryClientInterceptor(clientID string) grpc.UnaryClientInterceptor
UnaryClientInterceptor returns a grpc.UnaryClientInterceptor implementation that appends the client identifier to outgoing gRPC metadata under the X-Client-ID key.
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(fn Extractor) grpc.UnaryServerInterceptor
UnaryServerInterceptor is a grpc.UnaryServerInterceptor implementation that adds a ClientInfo to inbound contexts via the provided Extractor implementation.
Types ¶
type ClientInfo ¶
type ClientInfo struct {
ID string
}
The ClientInfo type describes the client as obtained via the inbound gRPC context.
func FromContext ¶
func FromContext(ctx context.Context) ClientInfo
FromContext obtains a ClientInfo instance from the provided context.Context. Returns a zero-value ClientInfo if one does not exist in the context.
func MetadataExtractor ¶
func MetadataExtractor(ctx context.Context) (ClientInfo, error)
MetadataExtractor is an Extractor implementation that attempts to generate a ClientInfo using the inbound context's metadata fields. The client identifier will be taken from the X-Client-ID metadata field.
func TLSExtractor ¶
func TLSExtractor(ctx context.Context) (ClientInfo, error)
TLSExtractor is an Extractor implementation that attempts to generate a ClientInfo using the client's TLS certificate. The client identifier will be the peer's SPIFFE identifier.