Movatterモバイル変換


[0]ホーム

URL:


metadata

package
v1.77.0Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License:Apache-2.0Imports:4Imported by:38,288

Details

Repository

github.com/grpc/grpc-go

Links

Documentation

Overview

Package metadata define the structure of the metadata supported by gRPC library.Please refer tohttps://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.mdfor more information about custom-metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcAppendToOutgoingContextadded inv1.10.0

func AppendToOutgoingContext(ctxcontext.Context, kv ...string)context.Context

AppendToOutgoingContext returns a new context with the provided kv mergedwith any existing metadata in the context. Please refer to the documentationof Pairs for a description of kv.

funcDecodeKeyValuedeprecated

func DecodeKeyValue(k, vstring) (string,string,error)

DecodeKeyValue returns k, v, nil.

Deprecated: use k and v directly instead.

funcNewIncomingContextadded inv1.3.0

func NewIncomingContext(ctxcontext.Context, mdMD)context.Context

NewIncomingContext creates a new context with incoming md attached. md mustnot be modified after calling this function.

funcNewOutgoingContextadded inv1.3.0

func NewOutgoingContext(ctxcontext.Context, mdMD)context.Context

NewOutgoingContext creates a new context with outgoing md attached. If usedin conjunction with AppendToOutgoingContext, NewOutgoingContext willoverwrite any previously-appended metadata. md must not be modified aftercalling this function.

funcValueFromIncomingContextadded inv1.50.0

func ValueFromIncomingContext(ctxcontext.Context, keystring) []string

ValueFromIncomingContext returns the metadata value corresponding to the metadatakey from the incoming metadata if it exists. Keys are matched in a case insensitivemanner.

Types

typeMD

type MD map[string][]string

MD is a mapping from metadata keys to values. Users should use the followingtwo convenience functions New and Pairs to generate MD.

funcFromIncomingContextadded inv1.3.0

func FromIncomingContext(ctxcontext.Context) (MD,bool)

FromIncomingContext returns the incoming metadata in ctx if it exists.

All keys in the returned MD are lowercase.

funcFromOutgoingContextadded inv1.3.0

func FromOutgoingContext(ctxcontext.Context) (MD,bool)

FromOutgoingContext returns the outgoing metadata in ctx if it exists.

All keys in the returned MD are lowercase.

funcJoinadded inv1.0.2

func Join(mds ...MD)MD

Join joins any number of mds into a single MD.

The order of values for each key is determined by the order in which the mdscontaining those values are presented to Join.

funcNew

func New(m map[string]string)MD

New creates an MD from a given key-value map.

Only the following ASCII characters are allowed in keys:

  • digits: 0-9
  • uppercase letters: A-Z (normalized to lower)
  • lowercase letters: a-z
  • special characters: -_.

Uppercase letters are automatically converted to lowercase.

Keys beginning with "grpc-" are reserved for grpc-internal use only and mayresult in errors if set in metadata.

funcPairs

func Pairs(kv ...string)MD

Pairs returns an MD formed by the mapping of key, value ...Pairs panics if len(kv) is odd.

Only the following ASCII characters are allowed in keys:

  • digits: 0-9
  • uppercase letters: A-Z (normalized to lower)
  • lowercase letters: a-z
  • special characters: -_.

Uppercase letters are automatically converted to lowercase.

Keys beginning with "grpc-" are reserved for grpc-internal use only and mayresult in errors if set in metadata.

func (MD)Appendadded inv1.12.0

func (mdMD) Append(kstring, vals ...string)

Append adds the values to key k, not overwriting what was already stored atthat key.

k is converted to lowercase before storing in md.

func (MD)Copy

func (mdMD) Copy()MD

Copy returns a copy of md.

func (MD)Deleteadded inv1.40.0

func (mdMD) Delete(kstring)

Delete removes the values for a given key k which is converted to lowercasebefore removing it from md.

func (MD)Getadded inv1.12.0

func (mdMD) Get(kstring) []string

Get obtains the values for a given key.

k is converted to lowercase before searching in md.

func (MD)Len

func (mdMD) Len()int

Len returns the number of items in md.

func (MD)Setadded inv1.12.0

func (mdMD) Set(kstring, vals ...string)

Set sets the value of a given key with a slice of values.

k is converted to lowercase before storing in md.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp