From 1635adc08aa413bbd7d2cf67e66ad6e9a823169a Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Fri, 2 Oct 2026 15:02:43 +0200 Subject: pathrouter: replace `vars` by new type Context This is a breaking change, but there are no real users of this package yet. I want to use the opportunity to have an extensible type here, esp. to later add a cheaper alternative to context.Context.WithValue() that is baked by just `map[reflect.Type]any` instead of a stack of contexts. --- pathrouter/pathrouter_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pathrouter/pathrouter_test.go') diff --git a/pathrouter/pathrouter_test.go b/pathrouter/pathrouter_test.go index 54108ac..96083ed 100644 --- a/pathrouter/pathrouter_test.go +++ b/pathrouter/pathrouter_test.go @@ -19,10 +19,10 @@ import ( func TestRouting(t *testing.T) { // helper methods varRx := regexp.MustCompile(`\$\w+`) - h := func(status int, msgBase string) func(w http.ResponseWriter, r *http.Request, vars map[string]string) { - return func(w http.ResponseWriter, r *http.Request, vars map[string]string) { + h := func(status int, msgBase string) pr.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request, rc pr.Context) { msg := varRx.ReplaceAllStringFunc(msgBase, func(match string) string { - return vars[strings.TrimPrefix(match, "$")] + return rc.Variable(strings.TrimPrefix(match, "$")) }) if r.Method == http.MethodHead { w.WriteHeader(status) -- cgit v1.3.1