mirror of
https://github.com/labstack/echo.git
synced 2024-12-22 20:06:21 +02:00
parent
c782b3fc75
commit
33c227045a
@ -379,10 +379,6 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
|
||||
// c = cn.getChild()
|
||||
if cn = cn.findChildByKind(mkind); cn == nil {
|
||||
// Not found
|
||||
if nn != nil { // Issue #217
|
||||
cn = nn
|
||||
continue
|
||||
}
|
||||
return
|
||||
}
|
||||
ctx.pvalues[len(cn.pnames)-1] = search
|
||||
|
@ -503,48 +503,6 @@ func TestRouterPriority(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Issue #217
|
||||
func TestRouterPriorityWithMatchAny(t *testing.T) {
|
||||
e := New()
|
||||
r := e.router
|
||||
|
||||
// Routes
|
||||
r.Add(GET, "/aa", func(c *Context) error {
|
||||
c.Set("a", 1)
|
||||
return nil
|
||||
}, e)
|
||||
r.Add(GET, "/ab", func(c *Context) error {
|
||||
c.Set("b", 2)
|
||||
return nil
|
||||
}, e)
|
||||
r.Add(GET, "/*", func(c *Context) error {
|
||||
c.Set("c", 3)
|
||||
return nil
|
||||
}, e)
|
||||
c := NewContext(nil, nil, e)
|
||||
|
||||
// Route > /aa
|
||||
h, _ := r.Find(GET, "/aa", c)
|
||||
if assert.NotNil(t, h) {
|
||||
h(c)
|
||||
assert.Equal(t, 1, c.Get("a"))
|
||||
}
|
||||
|
||||
// Route > /ab
|
||||
h, _ = r.Find(GET, "/ab", c)
|
||||
if assert.NotNil(t, h) {
|
||||
h(c)
|
||||
assert.Equal(t, 2, c.Get("b"))
|
||||
}
|
||||
|
||||
// Route > /*
|
||||
h, _ = r.Find(GET, "/abc", c)
|
||||
if assert.NotNil(t, h) {
|
||||
h(c)
|
||||
assert.Equal(t, 3, c.Get("c"))
|
||||
}
|
||||
}
|
||||
|
||||
func TestRouterParamNames(t *testing.T) {
|
||||
e := New()
|
||||
r := e.router
|
||||
|
Loading…
Reference in New Issue
Block a user