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 ¶
PatternFromContext returns the route pattern stored by WithPattern, or the empty string when no pattern has been set.
func WithPattern ¶
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.