Params

Reading path parameters, wildcards, and the matched route pattern.

The three params helpers wrap chi so a handler reads path data without importing it.

Param

func Param(r *http.Request, key string) string

Returns the named path parameter from the matched route, or an empty string when it is absent.

Wildcard

func Wildcard(r *http.Request) string

Returns the value matched by a trailing /* catch-all, or an empty string when the route had no wildcard.

RoutePattern

func RoutePattern(r *http.Request) string

Returns the matched route pattern, such as /items/{id}, which is a low-cardinality label for metrics and structured logging. Returns an empty string when called outside a matched route.