diff --git a/gzip/gzip.go b/gzip/gzip.go index 8b6f4fe..a44a944 100644 --- a/gzip/gzip.go +++ b/gzip/gzip.go @@ -27,7 +27,7 @@ var serveGzip = func(w http.ResponseWriter, r *http.Request, c martini.Context) gz := gzip.NewWriter(w) defer gz.Close() - gzw := gzipResponseWriter{gz, martini.NewResponseWriter(w)} + gzw := gzipResponseWriter{gz, w.(martini.ResponseWriter)} c.MapTo(gzw, (*http.ResponseWriter)(nil)) c.Next() diff --git a/gzip/gzip_test.go b/gzip/gzip_test.go index 2b3ba16..d1a430e 100644 --- a/gzip/gzip_test.go +++ b/gzip/gzip_test.go @@ -11,9 +11,15 @@ import ( func Test_GzipAll(t *testing.T) { // Set up recorder := httptest.NewRecorder() + before := false m := martini.New() m.Use(All()) + m.Use(func(r http.ResponseWriter) { + r.(martini.ResponseWriter).Before(func(rw martini.ResponseWriter) { + before = true + }) + }) r, err := http.NewRequest("GET", "/", nil) if err != nil { @@ -47,4 +53,8 @@ func Test_GzipAll(t *testing.T) { if !strings.EqualFold(ce, "gzip") { t.Error(HeaderContentEncoding + " is not 'gzip'") } + + if before == false { + t.Error("Before hook was not called") + } }