diff --git a/_fixture/favicon.ico b/_fixture/favicon.ico new file mode 100644 index 00000000..d939ddca Binary files /dev/null and b/_fixture/favicon.ico differ diff --git a/_fixture/folder/index.html b/_fixture/folder/index.html new file mode 100644 index 00000000..9b07a758 --- /dev/null +++ b/_fixture/folder/index.html @@ -0,0 +1,9 @@ + + + + + Echo + + + + diff --git a/test/fixture/walle.png b/_fixture/images/walle.png similarity index 100% rename from test/fixture/walle.png rename to _fixture/images/walle.png diff --git a/_fixture/index.html b/_fixture/index.html new file mode 100644 index 00000000..9b07a758 --- /dev/null +++ b/_fixture/index.html @@ -0,0 +1,9 @@ + + + + + Echo + + + + diff --git a/context_test.go b/context_test.go index 460c0d36..04f4ea8f 100644 --- a/context_test.go +++ b/context_test.go @@ -194,7 +194,7 @@ func TestContext(t *testing.T) { // File rec = httptest.NewRecorder() c = NewContext(req, NewResponse(rec, e), e) - err = c.File("test/fixture/walle.png", "", false) + err = c.File("_fixture/images/walle.png", "", false) if assert.NoError(t, err) { assert.Equal(t, http.StatusOK, rec.Code) assert.Equal(t, 219885, rec.Body.Len()) @@ -203,7 +203,7 @@ func TestContext(t *testing.T) { // File as attachment rec = httptest.NewRecorder() c = NewContext(req, NewResponse(rec, e), e) - err = c.File("test/fixture/walle.png", "WALLE.PNG", true) + err = c.File("_fixture/images/walle.png", "WALLE.PNG", true) if assert.NoError(t, err) { assert.Equal(t, http.StatusOK, rec.Code) assert.Equal(t, rec.Header().Get(ContentDisposition), "attachment; filename=WALLE.PNG") diff --git a/echo_test.go b/echo_test.go index 7bba3d7a..626e24d4 100644 --- a/echo_test.go +++ b/echo_test.go @@ -43,7 +43,7 @@ func TestEcho(t *testing.T) { func TestEchoIndex(t *testing.T) { e := New() - e.Index("recipes/website/public/index.html") + e.Index("_fixture/index.html") c, b := request(GET, "/", e) assert.Equal(t, http.StatusOK, c) assert.NotEmpty(t, b) @@ -51,7 +51,7 @@ func TestEchoIndex(t *testing.T) { func TestEchoFavicon(t *testing.T) { e := New() - e.Favicon("recipes/website/public/favicon.ico") + e.Favicon("_fixture/favicon.ico") c, b := request(GET, "/favicon.ico", e) assert.Equal(t, http.StatusOK, c) assert.NotEmpty(t, b) @@ -61,23 +61,23 @@ func TestEchoStatic(t *testing.T) { e := New() // OK - e.Static("/scripts", "recipes/website/public/scripts") - c, b := request(GET, "/scripts/main.js", e) + e.Static("/images", "_fixture/images") + c, b := request(GET, "/images/walle.png", e) assert.Equal(t, http.StatusOK, c) assert.NotEmpty(t, b) // No file - e.Static("/scripts", "recipes/website/public/scripts") - c, _ = request(GET, "/scripts/index.js", e) + e.Static("/images", "_fixture/scripts") + c, _ = request(GET, "/images/bolt.png", e) assert.Equal(t, http.StatusNotFound, c) // Directory - e.Static("/scripts", "recipes/website/public/scripts") - c, _ = request(GET, "/scripts", e) + e.Static("/images", "_fixture/images") + c, _ = request(GET, "/images", e) assert.Equal(t, http.StatusForbidden, c) // Directory with index.html - e.Static("/", "recipes/website/public") + e.Static("/", "_fixture") c, r := request(GET, "/", e) assert.Equal(t, http.StatusOK, c) assert.Equal(t, true, strings.HasPrefix(r, "")) @@ -85,7 +85,8 @@ func TestEchoStatic(t *testing.T) { // Sub-directory with index.html c, r = request(GET, "/folder", e) assert.Equal(t, http.StatusOK, c) - assert.Equal(t, "sub directory", r) + assert.Equal(t, true, strings.HasPrefix(r, "")) + // assert.Equal(t, "sub directory", r) } func TestEchoMiddleware(t *testing.T) { diff --git a/group.go b/group.go index 856a3365..56effb9c 100644 --- a/group.go +++ b/group.go @@ -48,6 +48,18 @@ func (g *Group) Trace(path string, h Handler) { g.echo.Trace(path, h) } +func (g *Group) Any(path string, h Handler) { + for _, m := range methods { + g.echo.add(m, path, h) + } +} + +func (g *Group) Match(methods []string, path string, h Handler) { + for _, m := range methods { + g.echo.add(m, path, h) + } +} + func (g *Group) WebSocket(path string, h HandlerFunc) { g.echo.WebSocket(path, h) } diff --git a/group_test.go b/group_test.go index f605993c..d4eebb3f 100644 --- a/group_test.go +++ b/group_test.go @@ -14,6 +14,8 @@ func TestGroup(t *testing.T) { g.Post("/", h) g.Put("/", h) g.Trace("/", h) + g.Any("/", h) + g.Match([]string{GET, POST}, "/", h) g.WebSocket("/ws", h) g.Static("/scripts", "scripts") g.ServeDir("/scripts", "scripts")