mirror of
https://github.com/labstack/echo.git
synced 2026-06-20 01:18:42 +02:00
- Moved static file serving to a new handler package
- Middleware at route level - Group middleware is a in closure now Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
@@ -35,13 +35,12 @@ func TestGzip(t *testing.T) {
|
||||
req := test.NewRequest(echo.GET, "/", nil)
|
||||
rec := test.NewResponseRecorder()
|
||||
c := echo.NewContext(req, rec, e)
|
||||
h := func(c echo.Context) error {
|
||||
// Skip if no Accept-Encoding header
|
||||
h := Gzip()(echo.HandlerFunc(func(c echo.Context) error {
|
||||
c.Response().Write([]byte("test")) // For Content-Type sniffing
|
||||
return nil
|
||||
}
|
||||
|
||||
// Skip if no Accept-Encoding header
|
||||
Gzip()(h)(c)
|
||||
}))
|
||||
h.Handle(c)
|
||||
// assert.Equal(t, http.StatusOK, rec.Status())
|
||||
assert.Equal(t, "test", rec.Body.String())
|
||||
|
||||
@@ -51,7 +50,7 @@ func TestGzip(t *testing.T) {
|
||||
c = echo.NewContext(req, rec, e)
|
||||
|
||||
// Gzip
|
||||
Gzip()(h)(c)
|
||||
h.Handle(c)
|
||||
// assert.Equal(t, http.StatusOK, rec.Status())
|
||||
assert.Equal(t, "gzip", rec.Header().Get(echo.ContentEncoding))
|
||||
assert.Contains(t, rec.Header().Get(echo.ContentType), echo.TextPlain)
|
||||
|
||||
Reference in New Issue
Block a user