From ed061708f4ce78b45224a4751389cd4f906473a9 Mon Sep 17 00:00:00 2001 From: Sylvain Muller Date: Fri, 30 Jun 2023 20:00:48 +0200 Subject: [PATCH] fix(auto-options): set the path parameter for the matched route (#23) --- fox.go | 2 ++ fox_test.go | 1 + 2 files changed, 3 insertions(+) diff --git a/fox.go b/fox.go index ddf8cb3..bb06223 100644 --- a/fox.go +++ b/fox.go @@ -323,6 +323,8 @@ NoMethodFallback: if n, _ := tree.lookup(nds[i], target, c.params, c.skipNds, true); n != nil { if sb.Len() > 0 { sb.WriteString(", ") + } else { + c.path = n.path } sb.WriteString(nds[i].key) } diff --git a/fox_test.go b/fox_test.go index a06177c..2a91d0f 100644 --- a/fox_test.go +++ b/fox_test.go @@ -1760,6 +1760,7 @@ func TestRouterWithAutomaticOptions(t *testing.T) { func TestRouterWithOptionsHandler(t *testing.T) { f := New(WithOptionsHandler(func(c Context) { + assert.Equal(t, "/foo/bar", c.Path()) c.Writer().WriteHeader(http.StatusNoContent) }))