Skip to content

Commit

Permalink
Merge pull request #40 from labstack/develop
Browse files Browse the repository at this point in the history
Nested groups
  • Loading branch information
Vishal Rana committed Apr 27, 2015
2 parents a956a03 + ff75c9c commit e3e16ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
13 changes: 13 additions & 0 deletions echo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e3e16ee

Please sign in to comment.