contextmap

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEndpointMiddleware

func NewEndpointMiddleware() endpoint.Middleware

NewEndpointMiddleware ensures that there is a ContextMap in the context of an endpoint.

Types

type ContextMap

type ContextMap interface {
	String() string
	WithCtx(context.Context) context.Context
	Set(key string, val interface{}) ContextMap
	Get(key string) interface{}
}

ContextMap provides a way to enrich a context.Context with information on lower layers and have this information available on the upper layers.

func Ctx

func Ctx(ctx context.Context) ContextMap

Ctx retrieved a ContextMap from the context.Context. If there isn't a ContextMap in the context, a noop ContextMap is returned, so it is safe to do something like Ctx(ctx).Set("key", "value").

func New

func New() ContextMap

New returns a new ContextMap that can be embedded in a context.Context.

Jump to

Keyboard shortcuts

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