ctxinjector

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: Apache-2.0 Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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