1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-24 20:14:31 +02:00
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2017-06-14 16:30:53 -07:00
parent ea352bedb6
commit 1b70cbebbe
3 changed files with 30 additions and 1 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@
coverage.txt
_test
vendor
.idea
*.iml

View File

@ -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

View File

@ -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