func AppendToOutgoingContext(ctx context.Context, kv ...string) context.Context
AppendToOutgoingContext returns a new context with the provided kv merged with any existing metadata in the context. Please refer to the documentation of Pairs for a description of kv.
func DecodeKeyValue(k, v string) (string, string, error)
DecodeKeyValue returns k, v, nil.
Deprecated: use k and v directly instead.
func NewIncomingContext(ctx context.Context, md MD) context.Context
NewIncomingContext creates a new context with incoming md attached. md must not be modified after calling this function.
func NewOutgoingContext(ctx context.Context, md MD) context.Context
NewOutgoingContext creates a new context with outgoing md attached. If used in conjunction with AppendToOutgoingContext, NewOutgoingContext will overwrite any previously-appended metadata. md must not be modified after calling this function.
func ValueFromIncomingContext(ctx context.Context, key string) []string
ValueFromIncomingContext returns the metadata value corresponding to the metadata key from the incoming metadata if it exists. Keys are matched in a case insensitive manner.
Notice: This API is EXPERIMENTAL and may be changed or removed in a later release.
MD is a mapping from metadata keys to values. Users should use the following two convenience functions New and Pairs to generate MD.
type MD map[string][]string
func FromIncomingContext(ctx context.Context) (MD, bool)
FromIncomingContext returns the incoming metadata in ctx if it exists.
All keys in the returned MD are lowercase.
func FromOutgoingContext(ctx context.Context) (MD, bool)
FromOutgoingContext returns the outgoing metadata in ctx if it exists.
All keys in the returned MD are lowercase.
func Join(mds ...MD) MD
Join joins any number of mds into a single MD.
The order of values for each key is determined by the order in which the mds containing those values are presented to Join.
func New(m map[string]string) MD
New creates an MD from a given key-value map.
Only the following ASCII characters are allowed in keys:
Uppercase letters are automatically converted to lowercase.
Keys beginning with "grpc-" are reserved for grpc-internal use only and may result in errors if set in metadata.
func Pairs(kv ...string) MD
Pairs returns an MD formed by the mapping of key, value ... Pairs panics if len(kv) is odd.
Only the following ASCII characters are allowed in keys:
Uppercase letters are automatically converted to lowercase.
Keys beginning with "grpc-" are reserved for grpc-internal use only and may result in errors if set in metadata.
func (md MD) Append(k string, vals ...string)
Append adds the values to key k, not overwriting what was already stored at that key.
k is converted to lowercase before storing in md.
func (md MD) Copy() MD
Copy returns a copy of md.
func (md MD) Delete(k string)
Delete removes the values for a given key k which is converted to lowercase before removing it from md.
func (md MD) Get(k string) []string
Get obtains the values for a given key.
k is converted to lowercase before searching in md.
func (md MD) Len() int
Len returns the number of items in md.
func (md MD) Set(k string, vals ...string)
Set sets the value of a given key with a slice of values.
k is converted to lowercase before storing in md.
func (md MD) String() string
String implements the Stringer interface for pretty-printing a MD. Ordering of the values is non-deterministic as it ranges over a map.