mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
parent
853e650ee2
commit
c9a581815a
2
echo.go
2
echo.go
@ -375,7 +375,7 @@ func (e *Echo) Static(path, dir string) {
|
||||
// ServeDir serves files from a directory.
|
||||
func (e *Echo) ServeDir(path, dir string) {
|
||||
e.Get(path+"*", func(c *Context) error {
|
||||
return serveFile(dir, c.P(0), c) // Param `_name`
|
||||
return serveFile(dir, c.P(0), c) // Param `_*`
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ func (r *Router) Add(method, path string, h HandlerFunc, e *Echo) {
|
||||
r.insert(method, path[:i], nil, ptype, pnames, e)
|
||||
} else if path[i] == '*' {
|
||||
r.insert(method, path[:i], nil, stype, nil, e)
|
||||
pnames = append(pnames, "_name")
|
||||
pnames = append(pnames, "_*")
|
||||
r.insert(method, path[:i+1], h, mtype, pnames, e)
|
||||
return
|
||||
}
|
||||
@ -351,7 +351,7 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
|
||||
// Look up for match-any, might have an empty value for *, e.g.
|
||||
// serving a directory. Issue #207
|
||||
cn = cn.findChildWithType(mtype)
|
||||
ctx.pvalues[len(ctx.pvalues)-1] = ""
|
||||
ctx.pvalues[len(cn.pnames)-1] = ""
|
||||
}
|
||||
continue
|
||||
}
|
||||
@ -395,7 +395,7 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
|
||||
c = cn.findChildWithType(mtype)
|
||||
if c != nil {
|
||||
cn = c
|
||||
ctx.pvalues[len(ctx.pvalues)-1] = search
|
||||
ctx.pvalues[len(cn.pnames)-1] = search
|
||||
search = "" // End search
|
||||
continue
|
||||
}
|
||||
|
@ -499,7 +499,7 @@ func TestRouterPriority(t *testing.T) {
|
||||
if assert.NotNil(t, h) {
|
||||
h(c)
|
||||
assert.Equal(t, 7, c.Get("g"))
|
||||
assert.Equal(t, "joe/books", c.Param("_name"))
|
||||
assert.Equal(t, "joe/books", c.Param("_*"))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user