fix: fixed crash when gzip was enabled

This commit is contained in:
Torkel Ödegaard
2017-05-22 14:09:54 +02:00
parent a64c06d02c
commit 7c50563f0f
5 changed files with 12 additions and 16 deletions
-14
View File
@@ -1,14 +0,0 @@
sudo: false
language: go
go:
- 1.3
- 1.4
- 1.5
- tip
script: go test -v -cover -race
notifications:
email:
- u@gogs.io
+4 -1
View File
@@ -86,7 +86,10 @@ func Gziper(options ...Options) macaron.Handler {
gzw := gzipResponseWriter{gz, ctx.Resp}
ctx.Resp = gzw
ctx.MapTo(gzw, (*http.ResponseWriter)(nil))
if ctx.Render != nil {
// Check if render middleware has been registered,
// if yes, we need to modify ResponseWriter for it as well.
if _, ok := ctx.Render.(*macaron.DummyRender); !ok {
ctx.Render.SetResponseWriter(gzw)
}