ctxlocal

package
v3.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package ctxlocal stores request locals without the allocation a variadic Locals call through the Ctx interface costs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Set

func Set(c fiber.Ctx, key, value any) any

Set stores value under key on c and returns what Locals returned.

Locals takes its value variadically. Reached through the Ctx interface the compiler cannot see that it only reads that argument, so the one-element "..." slice is heap-allocated on every call; the concrete method inlines and keeps it in the frame, which measured 50ns and a 16-byte allocation against 11ns and none. A custom Ctx fails the assertion and keeps the interface call, so an overridden Locals is still the one that runs. fiber's own StoreInContext does the same in-package; this is the form middleware and the extractors can reach.

Types

This section is empty.

Jump to

Keyboard shortcuts

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