1
0
mirror of https://github.com/labstack/echo.git synced 2025-03-21 21:27:04 +02:00

Merge pull request #40 from labstack/develop

Nested groups
This commit is contained in:
Vishal Rana 2015-04-26 18:10:22 -07:00
commit e3e16eeed6
2 changed files with 14 additions and 1 deletions

View File

@ -147,7 +147,7 @@ func New() (e *Echo) {
// the parent. Passing middleware overrides parent middleware.
func (e *Echo) Group(pfx string, m ...Middleware) *Echo {
g := *e
g.prefix = pfx
g.prefix = g.prefix + pfx
if len(m) > 0 {
g.middleware = nil
g.Use(m...)

View File

@ -218,6 +218,19 @@ func TestEchoGroup(t *testing.T) {
if b.String() != "3" {
t.Errorf("should execute middleware 3, executed %s", b.String())
}
// Nested group
g3 := e.Group("/group3")
g4 := g3.Group("/group4")
g4.Get("/home", func(c *Context) {
c.NoContent(http.StatusOK)
})
w = httptest.NewRecorder()
r, _ = http.NewRequest(GET, "/group3/group4/home", nil)
e.ServeHTTP(w, r)
if w.Code != 200 {
t.Errorf("status code should be 200, found %d", w.Code)
}
}
func TestEchoMethod(t *testing.T) {