Documentation ¶
Overview ¶
Package metadata define the structure of the metadata supported by gRPC library. Please refer to https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md for more information about custom-metadata.
Index ¶
- func AppendToOutgoingContext(ctx context.Context, kv ...string) context.Context
- func DecodeKeyValue(k, v string) (string, string, error)deprecated
- func NewIncomingContext(ctx context.Context, md MD) context.Context
- func NewOutgoingContext(ctx context.Context, md MD) context.Context
- type MD
- func AppendMD(md, other MD) MD
- func FromIncomingContext(ctx context.Context) (md MD, ok bool)
- func FromOutgoingContext(ctx context.Context) (MD, bool)
- func FromOutgoingContextRaw(ctx context.Context) (MD, [][]string, bool)
- func Join(mds ...MD) MD
- func New(m map[string]string) MD
- func Pairs(kv ...string) MD
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendToOutgoingContext ¶
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
deprecated
func NewIncomingContext ¶
NewIncomingContext creates a new context with incoming md attached.
Types ¶
type MD ¶
MD is a mapping from metadata keys to values. Users should use the following two convenience functions New and Pairs to generate MD.
func FromIncomingContext ¶
FromIncomingContext returns the incoming metadata in ctx if it exists. The returned MD should not be modified. Writing to it may cause races. Modification should be made to copies of the returned MD.
func FromOutgoingContext ¶
FromOutgoingContext returns the outgoing metadata in ctx if it exists. The returned MD should not be modified. Writing to it may cause races. Modification should be made to copies of the returned MD.
func FromOutgoingContextRaw ¶
FromOutgoingContextRaw returns the un-merged, intermediary contents of rawMD. Remember to perform strings.ToLower on the keys. The returned MD should not be modified. Writing to it may cause races. Modification should be made to copies of the returned MD.
This is intended for gRPC-internal use ONLY.
func Join ¶
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 ¶
New creates an MD from a given key-value map.
Only the following ASCII characters are allowed in keys:
- digits: 0-9
- uppercase letters: A-Z (normalized to lower)
- lowercase letters: a-z
- special characters: -_.
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 ¶
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:
- digits: 0-9
- uppercase letters: A-Z (normalized to lower)
- lowercase letters: a-z
- special characters: -_.
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.