mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
Fixed nested groups, reset Context#handler
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
86ddfedb45
commit
296498c942
@ -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
|
||||
}
|
||||
|
6
echo.go
6
echo.go
@ -141,12 +141,6 @@ const (
|
||||
WWWAuthenticate = "WWW-Authenticate"
|
||||
XForwardedFor = "X-Forwarded-For"
|
||||
XRealIP = "X-Real-IP"
|
||||
|
||||
//-----------
|
||||
// Protocols
|
||||
//-----------
|
||||
|
||||
WebSocket = "websocket"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
2
group.go
2
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) {
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user