mirror of
https://github.com/labstack/echo.git
synced 2024-12-22 20:06:21 +02:00
parent
49c099c3b3
commit
1659348a67
2
group.go
2
group.go
@ -12,6 +12,8 @@ func (g *Group) Use(m ...Middleware) {
|
||||
for _, h := range m {
|
||||
g.echo.middleware = append(g.echo.middleware, wrapMiddleware(h))
|
||||
}
|
||||
|
||||
g.echo.Any(g.echo.prefix+"*", notFoundHandler)
|
||||
}
|
||||
|
||||
// Connect implements the echo.Connect interface for subroutes within the Group.
|
||||
|
@ -344,7 +344,7 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
|
||||
// Static node
|
||||
if c = cn.findChild(search[0], skind); c != nil {
|
||||
// Save next
|
||||
if cn.label == '/' {
|
||||
if cn.prefix[len(cn.prefix)-1] == '/' {
|
||||
nk = pkind
|
||||
nn = cn
|
||||
ns = search
|
||||
@ -362,7 +362,7 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
|
||||
}
|
||||
|
||||
// Save next
|
||||
if cn.label == '/' {
|
||||
if cn.prefix[len(cn.prefix)-1] == '/' {
|
||||
nk = akind
|
||||
nn = cn
|
||||
ns = search
|
||||
|
@ -606,6 +606,37 @@ func TestRouterParamNames(t *testing.T) {
|
||||
assert.Equal(t, "1", c.P(1))
|
||||
}
|
||||
|
||||
func TestRouterStaticDynamicConflict(t *testing.T) {
|
||||
e := New()
|
||||
r := e.router
|
||||
c := NewContext(nil, nil, e)
|
||||
|
||||
r.Add(GET, "/dictionary/skills", func(c *Context) error {
|
||||
c.Set("a", 1)
|
||||
return nil
|
||||
}, e)
|
||||
r.Add(GET, "/dictionary/:name", func(c *Context) error {
|
||||
c.Set("b", 2)
|
||||
return nil
|
||||
}, e)
|
||||
r.Add(GET, "/server", func(c *Context) error {
|
||||
c.Set("c", 3)
|
||||
return nil
|
||||
}, e)
|
||||
|
||||
h, _ := r.Find(GET, "/dictionary/skills", c)
|
||||
h(c)
|
||||
assert.Equal(t, 1, c.Get("a"))
|
||||
c = NewContext(nil, nil, e)
|
||||
h, _ = r.Find(GET, "/dictionary/type", c)
|
||||
h(c)
|
||||
assert.Equal(t, 2, c.Get("b"))
|
||||
c = NewContext(nil, nil, e)
|
||||
h, _ = r.Find(GET, "/server", c)
|
||||
h(c)
|
||||
assert.Equal(t, 3, c.Get("c"))
|
||||
}
|
||||
|
||||
func TestRouterAPI(t *testing.T) {
|
||||
e := New()
|
||||
r := e.router
|
||||
|
Loading…
Reference in New Issue
Block a user