From 296498c9423a21ff893eae674849b4d793909feb Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Tue, 8 Mar 2016 19:31:11 -0800 Subject: [PATCH] Fixed nested groups, reset Context#handler Signed-off-by: Vishal Rana --- context.go | 1 + echo.go | 6 ------ echo_test.go | 8 ++++---- group.go | 2 +- middleware/auth.go | 5 ----- router.go | 2 -- 6 files changed, 6 insertions(+), 18 deletions(-) diff --git a/context.go b/context.go index da2086a6..25318738 100644 --- a/context.go +++ b/context.go @@ -325,4 +325,5 @@ func (c *context) reset(req engine.Request, res engine.Response) { c.response = res c.query = nil c.store = nil + c.handler = notFoundHandler } diff --git a/echo.go b/echo.go index 0edb3ace..8b1af536 100644 --- a/echo.go +++ b/echo.go @@ -141,12 +141,6 @@ const ( WWWAuthenticate = "WWW-Authenticate" XForwardedFor = "X-Forwarded-For" XRealIP = "X-Real-IP" - - //----------- - // Protocols - //----------- - - WebSocket = "websocket" ) var ( diff --git a/echo_test.go b/echo_test.go index 47da96e1..e662960f 100644 --- a/echo_test.go +++ b/echo_test.go @@ -222,22 +222,22 @@ func TestEchoGroup(t *testing.T) { return h.Handle(c) }) })) - g1.Get("/", h) + g1.Get("", h) // Nested groups g2 := e.Group("/group2") g3 := g2.Group("/group3") - g3.Get("/", h) + g3.Get("", h) request(GET, "/users", e) assert.Equal(t, "0", buf.String()) buf.Reset() - request(GET, "/group1/", e) + request(GET, "/group1", e) assert.Equal(t, "01", buf.String()) buf.Reset() - c, _ := request(GET, "/group2/group3/", e) + c, _ := request(GET, "/group2/group3", e) assert.Equal(t, http.StatusOK, c) } diff --git a/group.go b/group.go index 1e97ba59..65ea8a88 100644 --- a/group.go +++ b/group.go @@ -61,7 +61,7 @@ func (g *Group) Match(methods []string, path string, handler Handler, middleware } func (g *Group) Group(prefix string, m ...Middleware) *Group { - return g.echo.Group(prefix, m...) + return g.echo.Group(g.prefix+prefix, m...) } func (g *Group) add(method, path string, handler Handler, middleware ...Middleware) { diff --git a/middleware/auth.go b/middleware/auth.go index cfe51c73..fca6cc7f 100644 --- a/middleware/auth.go +++ b/middleware/auth.go @@ -25,11 +25,6 @@ const ( func BasicAuth(fn BasicAuthFunc, options ...*BasicAuthOptions) echo.MiddlewareFunc { return func(next echo.Handler) echo.Handler { return echo.HandlerFunc(func(c echo.Context) error { - // Skip WebSocket - if (c.Request().Header().Get(echo.Upgrade)) == echo.WebSocket { - return nil - } - auth := c.Request().Header().Get(echo.Authorization) l := len(basic) diff --git a/router.go b/router.go index 859e9269..0e722072 100644 --- a/router.go +++ b/router.go @@ -282,8 +282,6 @@ func (n *node) check405() HandlerFunc { func (r *Router) Find(method, path string, context Context) { ctx := context.Object() - // h = notFoundHandler - // e = r.echo cn := r.tree // Current node as root var (