context

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package context provides functions which can be used to set/get values to/from context.Context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValue

func GetValue[T any](ctx context.Context, key Key) *T

GetValue returns a value by key from the context.

func Logger

func Logger(ctx context.Context) *slog.Logger

Logger returns the logger stored in the context or a NopLogger.

func ShowErrors

func ShowErrors(ctx context.Context) bool

ShowErrors returns if errors should be shown in [httptools.ServerErrorResponse.].

func WithLogger

func WithLogger(ctx context.Context, logger *slog.Logger) context.Context

WithLogger sets the logger on the context.

func WithShownErrors

func WithShownErrors(ctx context.Context) context.Context

WithShownErrors enables showing errors of [httptools.ServerErrorResponse].

Types

type Key

type Key string

Key is the type used for specifying context keys.

Jump to

Keyboard shortcuts

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