metadatax

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 4 Imported by: 0

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