Documentation ¶
Index ¶
- type MD
- func (m MD) Add(key string, value string) MD
- func (m MD) Clone(copiedKeys ...string) MD
- func (m MD) Del(key string) MD
- func (m MD) Get(key string) string
- func (m MD) Set(key string, value string) MD
- func (m MD) ToIncoming(ctx context.Context) context.Context
- func (m MD) ToOutgoing(ctx context.Context) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MD ¶
type MD grpcMetadata.MD
MD is a convenience wrapper defining extra functions on the metadata.
func ExtractIncoming ¶
ExtractIncoming extracts an inbound metadata from the server-side context.
This function always returns MD wrapper of the grpcMetadata.MD, in case the context doesn't have metadata it returns a new empty MD.
func ExtractOutgoing ¶
ExtractOutgoing extracts an outbound metadata from the client-side context.
This function always returns MD wrapper of the grpcMetadata.MD, in case the context doesn't have metadata it returns a new empty MD.
func (MD) Add ¶
Add retrieves a single value from the metadata.
It works analogously to http.Header.Add, as it appends to any existing values associated with key.
The function is binary-key safe.
func (MD) Clone ¶
Clone performs a *deep* copy of the grpcMetadata.MD.
You can specify the lower-case copiedKeys to only copy certain whitelisted keys. If no keys are explicitly whitelisted all keys get copied.
func (MD) Get ¶
Get retrieves a single value from the metadata.
It works analogously to http.Header.Get, returning the first value if there are many set. If the value is not set, an empty string is returned.
The function is binary-key safe.
func (MD) Set ¶
Set sets the given value in a metadata.
It works analogously to http.Header.Set, overwriting all previous metadata values.
The function is binary-key safe.
func (MD) ToIncoming ¶
ToIncoming sets the given MD as a server-side context for dispatching.
This is mostly useful in ServerInterceptors.