1
0
mirror of https://github.com/labstack/echo.git synced 2025-01-26 03:20:08 +02:00

Merge branch 'pr/39' into develop

This commit is contained in:
Vishal Rana 2015-04-26 17:28:45 -07:00
commit 35680ab9cb
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. // the parent. Passing middleware overrides parent middleware.
func (e *Echo) Group(pfx string, m ...Middleware) *Echo { func (e *Echo) Group(pfx string, m ...Middleware) *Echo {
g := *e g := *e
g.prefix = pfx g.prefix = g.prefix + pfx
if len(m) > 0 { if len(m) > 0 {
g.middleware = nil g.middleware = nil
g.Use(m...) g.Use(m...)

View File

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