ctxinjector

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CtxInjector

type CtxInjector struct {
	// contains filtered or unexported fields
}

CtxInjector is a context injector that injects key-value pairs into a context. When list of injector is not defined, it does nothing.

func NewCtxInjector

func NewCtxInjector(injectors ...KeyValueInjectorFunc) CtxInjector

NewCtxInjector creates a new context injector with the given injectors.

func (*CtxInjector) InjectKeyValues

func (ci *CtxInjector) InjectKeyValues(ctx context.Context) context.Context

InjectKeyValues injects key-value pairs into a context and returns the new context. It iterates over the injectors and calls each one to get a key-value pair to inject.

func (*CtxInjector) Register

func (ci *CtxInjector) Register(injector ...KeyValueInjectorFunc)

Register adds a new injector to the context injector.

type KeyValueInjectorFunc

type KeyValueInjectorFunc func() (key any, value any)

KeyValueInjectorFunc is type of a function that returns a key-value pair to be injected into a context.

Jump to

Keyboard shortcuts

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