Closed
Description
Issue Description
I had created routes using GET and PUT with path parameters. Using the same names in both works fine, but if the names are different it doesn't work.
Checklist
- Dependencies installed
- No typos
- Searched existing issues and docs
Expected behaviour
I would expect each path to own its own path parameters.
Actual behaviour
Not all path parameters expected are found. The order or declaration affects which ones are missing.
Steps to reproduce
In router_test.go
, change TestRouterTwoParam
to have both GET and PUT paths and for these to have distinct parameter names.
func TestRouterTwoParam(t *testing.T) {
e := New()
r := e.router
r.Add(http.MethodPut, "/users/:vid/files/:gid", func(Context) error {
return nil
})
r.Add(http.MethodGet, "/users/:uid/files/:fid", func(Context) error {
return nil
})
c := e.NewContext(nil, nil).(*context)
r.Find(http.MethodGet, "/users/1/files/2", c)
assert.Equal(t, "1", c.Param("uid"))
assert.Equal(t, "2", c.Param("fid"))
r.Find(http.MethodPut, "/users/3/files/4", c)
assert.Equal(t, "3", c.Param("vid"))
assert.Equal(t, "4", c.Param("gid"))
}
This test fails. If the two Add
statements are swapped, it still fails but in a different place.
Version/commit
v4.1.17-99-g936c48a
Metadata
Metadata
Assignees
Labels
No labels