contextutil

package
v0.85.0-pre.7 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store[T any] struct {
	// contains filtered or unexported fields
}

Store provides a typed key for context and request value access.

func NewStore

func NewStore[T any](key string) *Store[T]

NewStore creates a typed context store bound to a stable key name.

func (*Store[T]) ContextWithValue

func (s *Store[T]) ContextWithValue(c context.Context, val T) context.Context

ContextWithValue returns a derived context carrying val.

func (*Store[T]) RequestWithContextValue

func (s *Store[T]) RequestWithContextValue(
	r *http.Request,
	val T,
) *http.Request

RequestWithContextValue returns a request with val attached to its context.

func (*Store[T]) Value

func (s *Store[T]) Value(c context.Context) T

Value reads a typed value from context or returns the zero value.

Jump to

Keyboard shortcuts

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