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:
commit
35680ab9cb
2
echo.go
2
echo.go
@ -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...)
|
||||
|
13
echo_test.go
13
echo_test.go
@ -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("/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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user