From c9a581815ab2084f7066aa4c2726623e256cfb3d Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Thu, 17 Sep 2015 08:11:35 -0700 Subject: [PATCH] Fixed #210 Signed-off-by: Vishal Rana --- echo.go | 2 +- router.go | 6 +++--- router_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/echo.go b/echo.go index b87d9ca5..84473f1d 100644 --- a/echo.go +++ b/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 `_*` }) } diff --git a/router.go b/router.go index a63af596..7b156fa9 100644 --- a/router.go +++ b/router.go @@ -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 } diff --git a/router_test.go b/router_test.go index e1d38df0..40a1e62b 100644 --- a/router_test.go +++ b/router_test.go @@ -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("_*")) } }