Documentation
¶
Index ¶
- func AppendToOutgoingContext(ctx context.Context, k string, v ...string) context.Context
- func NewIncomingContext(ctx context.Context, md MD) context.Context
- func NewOutgoingContext(ctx context.Context, md MD) context.Context
- func ValueFromIncomingContext(ctx context.Context, key string) string
- type MD
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendToOutgoingContext ¶
AppendToOutgoingContext returns a new context with the provided kv added to the existing outgoing metadata. This will overwrite any previously-appended metadata. This will modify the provided context.
func NewIncomingContext ¶
NewIncomingContext creates a new context with incoming md attached.
func NewOutgoingContext ¶
NewOutgoingContext creates a new context with outgoing md attached. If used in conjunction with AppendToOutgoingContext, NewOutgoingContext will overwrite any previously-appended metadata.
Types ¶
type MD ¶
A MD represents the key-value pairs in an RPC Metadata.
The keys should be in canonical form, as returned by [CanonicalHeaderKey].
func FromIncomingContext ¶
FromIncomingContext returns the incoming metadata in ctx and will always be a non-nil map.
func FromOutgoingContext ¶
FromIncomingContext returns the incoming metadata in ctx if it exists.
func Pairs ¶
Pairs returns an MD formed by the mapping of key, value ... Pairs panics if len(kv) is odd.
The key is case insensitive; it is canonicalized by [CanonicalHeaderKey].
Keys beginning with "grpc-" are reserved for grpc-internal use only and may result in errors if set in metadata.
func (MD) Add ¶
Add adds the key, value pair to the header. It appends to any existing values associated with key. The key is case insensitive; it is canonicalized by [CanonicalHeaderKey].
func (MD) Del ¶
Del deletes the values associated with key. The key is case insensitive; it is canonicalized by [CanonicalHeaderKey].
func (MD) Get ¶
Get gets the first value associated with the given key. If there are no values associated with the key, Get returns "". It is case insensitive; textproto.CanonicalMIMEHeaderKey is used to canonicalize the provided key. Get assumes that all keys are stored in canonical form. To use non-canonical keys, access the map directly.
func (MD) Set ¶
Set sets the header entries associated with key to the single element value. It replaces any existing values associated with key. The key is case insensitive; it is canonicalized by textproto.CanonicalMIMEHeaderKey. To use non-canonical keys, assign to the map directly.
func (MD) Values ¶
Values returns all values associated with the given key. It is case insensitive; textproto.CanonicalMIMEHeaderKey is used to canonicalize the provided key. To use non-canonical keys, access the map directly. The returned slice is not a copy.