grpc_metadata

package module
v0.0.0-...-be8cff6 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2019 License: MIT Imports: 2 Imported by: 2

README

grpc-metadata

Convenience functions for accessing gRPC metadata

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAccountID

func GetAccountID(ctx context.Context) string

GetAccountID tries to extract the accountId key from the given context. If no AccountID exists, an empty string is returned.

func GetMetadata

func GetMetadata(ctx context.Context) (metadata.MD, bool)

GetMetadata is a convenience function which can be used in order to not have to import two metadata libraries (grpc/metadata and go-godin/metadata)

func GetRequestID

func GetRequestID(ctx context.Context) string

GetRequestID tries to extract the requestId key from the given context.

func GetUserID

func GetUserID(ctx context.Context) string

GetUserID tries to extract the userId key from the given context. If no UserID exists, an empty string is returned

func Has

func Has(ctx context.Context, key MetadataContextKey) bool

Has checks whether the passed key exists in the context metadata

func HasAccountID

func HasAccountID(ctx context.Context) bool

func HasUserID

func HasUserID(ctx context.Context) bool

Types

type MetadataContextKey

type MetadataContextKey string
const (
	RequestID MetadataContextKey = "requestId"
	AccountID MetadataContextKey = "accountId"
	UserID    MetadataContextKey = "userId"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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