metadata

package
v0.0.0-...-9eed78a Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToClientContext

func AppendToClientContext(ctx context.Context, kv ...string) context.Context

AppendToClientContext returns a new context with the provided kv merged with any existing metadata in the context.

func MergeToClientContext

func MergeToClientContext(ctx context.Context, otherMD Metadata) context.Context

MergeToClientContext merges new metadata into ctx

func NewClientContext

func NewClientContext(ctx context.Context, md Metadata) context.Context

NewClientContext create a new context with client metadata attached.

func NewServerContext

func NewServerContext(ctx context.Context, md Metadata) context.Context

NewServerContext create a new context with server metadata attached.

Types

type Metadata

type Metadata map[string][]string

Metadata is the way of representing request headers internally.

func FromClientContext

func FromClientContext(ctx context.Context) (Metadata, bool)

FromClientContext returns the client metadata in context if it exists.

func FromServerContext

func FromServerContext(ctx context.Context) (Metadata, bool)

FromServerContext returns the server metadata in context if it exists.

func New

func New(mds ...map[string][]string) Metadata

func (Metadata) Add

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

Add the key-value pair to the header

func (Metadata) Clone

func (m Metadata) Clone() Metadata

Clone returns a deep copy of Metadata

func (Metadata) Get

func (m Metadata) Get(key string) string

Get the value associated with the passed key

func (Metadata) Range

func (m Metadata) Range(f func(k string, vs []string) bool)

Range iterate over element in metadata

func (Metadata) Set

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

Set the key-value pair

func (Metadata) Values

func (m Metadata) Values(key string) []string

Values returns a slice of values associated with the passed key

Jump to

Keyboard shortcuts

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