httproute

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package httproute propagates a matched HTTP route pattern through a request context as an immutable string. It is a leaf package with no dependencies beyond the standard library so any layer of the middleware stack can import it without introducing import cycles.

The pattern is set once by the observation layer (before the inner handler runs) using an independent chi route-context lookup, then read after the inner handler returns. Stashing it as a plain string avoids sharing a mutable chi.RouteContext across a timeout boundary, which would race when http.TimeoutHandler returns concurrently with the inner chi mux still mutating the context's RoutePatterns slice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PatternFromContext

func PatternFromContext(ctx context.Context) string

PatternFromContext returns the route pattern stored by WithPattern, or the empty string when no pattern has been set.

func WithPattern

func WithPattern(ctx context.Context, pattern string) context.Context

WithPattern returns a derived context carrying pattern as the matched route. Callers should pass the pattern string obtained from an independent chi route lookup performed on a private, non-shared route context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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