1
0
mirror of https://github.com/labstack/echo.git synced 2024-11-24 08:22:21 +02:00
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2015-09-17 08:11:35 -07:00
parent 853e650ee2
commit c9a581815a
3 changed files with 5 additions and 5 deletions

View File

@ -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 `_*`
})
}

View File

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

View File

@ -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("_*"))
}
}