summaryrefslogtreecommitdiff
path: root/pathrouter/pathrouter_test.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-10-02 15:02:43 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-10-02 15:02:43 +0200
commit1635adc08aa413bbd7d2cf67e66ad6e9a823169a (patch)
treee85a855893ce3632d3d43e58891208653fb70cb8 /pathrouter/pathrouter_test.go
parent7b1cca50c21a6156824e276e2b6c662d33cc9071 (diff)
downloadgo-gg-1635adc08aa413bbd7d2cf67e66ad6e9a823169a.tar.gz
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.
Diffstat (limited to 'pathrouter/pathrouter_test.go')
-rw-r--r--pathrouter/pathrouter_test.go6
1 files changed, 3 insertions, 3 deletions
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)