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 {
|
for _, h := range m {
|
||||||
g.echo.middleware = append(g.echo.middleware, wrapMiddleware(h))
|
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.
|
// 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
|
// Static node
|
||||||
if c = cn.findChild(search[0], skind); c != nil {
|
if c = cn.findChild(search[0], skind); c != nil {
|
||||||
// Save next
|
// Save next
|
||||||
if cn.label == '/' {
|
if cn.prefix[len(cn.prefix)-1] == '/' {
|
||||||
nk = pkind
|
nk = pkind
|
||||||
nn = cn
|
nn = cn
|
||||||
ns = search
|
ns = search
|
||||||
@ -362,7 +362,7 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save next
|
// Save next
|
||||||
if cn.label == '/' {
|
if cn.prefix[len(cn.prefix)-1] == '/' {
|
||||||
nk = akind
|
nk = akind
|
||||||
nn = cn
|
nn = cn
|
||||||
ns = search
|
ns = search
|
||||||
|
@ -606,6 +606,37 @@ func TestRouterParamNames(t *testing.T) {
|
|||||||
assert.Equal(t, "1", c.P(1))
|
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) {
|
func TestRouterAPI(t *testing.T) {
|
||||||
e := New()
|
e := New()
|
||||||
r := e.router
|
r := e.router
|
||||||
|
Loading…
Reference in New Issue
Block a user