Documentation
¶
Index ¶
- func AppendToClientContext(ctx context.Context, kv ...string) context.Context
- func MergeToClientContext(ctx context.Context, cmd Metadata) context.Context
- func NewClientContext(ctx context.Context, md Metadata) context.Context
- func NewServerContext(ctx context.Context, md Metadata) context.Context
- type Metadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendToClientContext ¶
AppendToClientContext returns a new context with the provided kv merged with any existing metadata in the context. This functions is a modification of grpc.AppendToOutgoingContext
func MergeToClientContext ¶
MergeToClientContext merge new metadata into ctx.
func NewClientContext ¶
NewClientContext creates a new context with client md attached. This function is implemented in the same way as in NewServerContext and grpc.NewIncomingContext
Types ¶
type Metadata ¶
Metadata is our way of representing request headers internally. They're used at the RPC level and translate back and forth from Transport headers.
func FromClientContext ¶
FromClientContext returns the client metadata in ctx if it exists. 从context中获取client metadata
func FromServerContext ¶
FromServerContext returns the server metadata in ctx if it exists. This function is a modification of grpc.fromOutgoingContextRaw
func New ¶
New creates an MD from a given key-values map. Different the metadata.New from grpc.metadata, this function will not convert the key to lowercase. This function allow to input multi map[string] with the velue is []string In the return Metadata, a key may appear corresponding to multiple values.