lazycontext

package module
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: BSD-3-Clause Imports: 3 Imported by: 3

Documentation

Overview

lazycontext provides acumulative context that can store values like context.Context or by type

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T any](app context.Context) T

Get retrieves the last value added to the context with the given type

func Set

func Set[T any](ctx AppContext, value T)

Set stores a value in the context using the type of the value as the key

Types

type AppContext

type AppContext interface {
	context.Context
	AddValue(key any, value any) AppContext
}

AppContext is a small wrapper around the context.AppContext type that provides a more convenient API

func FromContext

func FromContext(ctx context.Context) (AppContext, bool)

FromContext retrieves the Context from a context.Context

func New

func New() AppContext

New creates a new Context

func NewWithContext

func NewWithContext(ctx context.Context) AppContext

NewWithContext creates a new Context from a context.Context

Jump to

Keyboard shortcuts

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