metadata

package
v2.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 4 Imported by: 38

Documentation

Index

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

func ExtractIncoming(ctx context.Context) MD

ExtractIncoming extracts an inbound metadata from the server-side context.

This function always returns a MD wrapper of the grpcMetadata.MD, in case the context doesn't have metadata it returns a new empty MD.

func ExtractOutgoing

func ExtractOutgoing(ctx context.Context) MD

ExtractOutgoing extracts an outbound metadata from the client-side context.

This function always returns a MD wrapper of the grpcMetadata.MD, in case the context doesn't have metadata it returns a new empty MD.

func (MD) Add

func (m MD) Add(key string, value string) MD

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

func (m MD) Clone(copiedKeys ...string) MD

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) Del

func (m MD) Del(key string) MD

func (MD) Get

func (m MD) Get(key string) string

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

func (m MD) Set(key string, value string) MD

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

func (m MD) ToIncoming(ctx context.Context) context.Context

ToIncoming sets the given MD as a server-side context for dispatching.

This is mostly useful in ServerInterceptors.

func (MD) ToOutgoing

func (m MD) ToOutgoing(ctx context.Context) context.Context

ToOutgoing sets the given MD as a client-side context for dispatching.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL