grpc: google.golang.org/grpc/metadata Index | Files

package metadata

import "google.golang.org/grpc/metadata"

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

Package Files

metadata.go

func AppendToOutgoingContext Uses

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 Uses

func DecodeKeyValue(k, v string) (string, string, error)

DecodeKeyValue returns k, v, nil.

Deprecated: use k and v directly instead.

func NewIncomingContext Uses

func NewIncomingContext(ctx context.Context, md MD) context.Context

NewIncomingContext creates a new context with incoming md attached.

func NewOutgoingContext Uses

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.

type MD Uses

type MD map[string][]string

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 Uses

func FromIncomingContext(ctx context.Context) (md MD, ok bool)

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 Uses

func FromOutgoingContext(ctx context.Context) (MD, bool)

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 Uses

func FromOutgoingContextRaw(ctx context.Context) (MD, [][]string, bool)

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 Uses

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 Uses

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:

- 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 Uses

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:

- 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 (MD) Append Uses

func (md MD) Append(k string, vals ...string)

Append adds the values to key k, not overwriting what was already stored at that key.

func (MD) Copy Uses

func (md MD) Copy() MD

Copy returns a copy of md.

func (MD) Get Uses

func (md MD) Get(k string) []string

Get obtains the values for a given key.

func (MD) Len Uses

func (md MD) Len() int

Len returns the number of items in md.

func (MD) Set Uses

func (md MD) Set(k string, vals ...string)

Set sets the value of a given key with a slice of values.

Package metadata imports 3 packages (graph) and is imported by 1051 packages. Updated 2018-11-13. Refresh now. Tools for package owners.