mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
parent
ea352bedb6
commit
1b70cbebbe
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,3 +2,5 @@
|
||||
coverage.txt
|
||||
_test
|
||||
vendor
|
||||
.idea
|
||||
*.iml
|
||||
|
@ -394,7 +394,7 @@ func (r *Router) Find(method, path string, c Context) {
|
||||
if cn = cn.findChildByKind(akind); cn == nil {
|
||||
if nn != nil {
|
||||
cn = nn
|
||||
nn = nil // Next
|
||||
nn = cn.parent // Next (Issue #954)
|
||||
search = ns
|
||||
if nk == pkind {
|
||||
goto Param
|
||||
|
@ -584,6 +584,33 @@ func TestRouterMatchAny(t *testing.T) {
|
||||
assert.Equal(t, "joe", c.Param("*"))
|
||||
}
|
||||
|
||||
func TestRouterMatchAnyMultiLevel(t *testing.T) {
|
||||
e := New()
|
||||
r := e.router
|
||||
handler := func(c Context) error {
|
||||
c.Set("path", c.Path())
|
||||
return nil
|
||||
}
|
||||
|
||||
// Routes
|
||||
r.Add(GET, "/api/users/jack", handler)
|
||||
r.Add(GET, "/api/users/jill", handler)
|
||||
r.Add(GET, "/*", handler)
|
||||
|
||||
c := e.NewContext(nil, nil).(*context)
|
||||
r.Find(GET, "/api/users/jack", c)
|
||||
c.handler(c)
|
||||
assert.Equal(t, "/api/users/jack", c.Get("path"))
|
||||
|
||||
r.Find(GET, "/api/users/jill", c)
|
||||
c.handler(c)
|
||||
assert.Equal(t, "/api/users/jill", c.Get("path"))
|
||||
|
||||
r.Find(GET, "/api/users/joe", c)
|
||||
c.handler(c)
|
||||
assert.Equal(t, "/*", c.Get("path"))
|
||||
}
|
||||
|
||||
func TestRouterMicroParam(t *testing.T) {
|
||||
e := New()
|
||||
r := e.router
|
||||
|
Loading…
Reference in New Issue
Block a user