injectz

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: MIT Imports: 3 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize(initializers ...Initializer) (Injector, Releaser)

Initialize calls all initializers and returns a compound Injector and Releaser. If an initializer panics, previous releasers are invoked before propagating it.

func NewMiddleware

func NewMiddleware(injector Injector) func(handler http.Handler) http.Handler

NewMiddleware creates a new HTTP server middleware that enriches context using the given Injector.

Types

type Initializer

type Initializer func(ctx context.Context) (Injector, Releaser)

Initializer initializes a value, returning a corresponding Injector and Releaser.

type Injector

type Injector func(ctx context.Context) context.Context

Injector injects values into a Context.

func NewInjectors

func NewInjectors(injectors ...Injector) Injector

NewInjectors combines multiple injectors into one.

func NewSingletonInjector

func NewSingletonInjector(contextKey, value interface{}) Injector

NewSingletonInjector always injects the given value using the given context key.

type Releaser

type Releaser func()

Releaser releases an initialized resource.

func NewCloseReleaser

func NewCloseReleaser(closer io.Closer) Releaser

NewCloseReleaser returns a releaser that calls closer.Close, ignoring any returned error.

func NewNoopReleaser

func NewNoopReleaser() Releaser

NewNoopReleaser returns a releaser that does nothing.

func NewReleasers

func NewReleasers(releasers ...Releaser) Releaser

NewReleasers combines multiple releasers into one (invoking them in reverse order).

Directories

Path Synopsis
internal
fixtures
Package fixtures is a generated GoMock package.
Package fixtures is a generated GoMock package.

Jump to

Keyboard shortcuts

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