gzip icon indicating copy to clipboard operation
gzip copied to clipboard

Attempting to use this results in gzipped files downloading

Open JaTochNietDan opened this issue 11 years ago • 3 comments

So when using this it constantly results in my browser downloading a gzipped file. I also get a panic from Martini saying the following:

[martini] PANIC: interface conversion: *martini.responseWriter is not martini.ResponseWriter: missing method Before

My code is as follows:

m := martini.Classic()
m.Use(gzip.All())
m.Use(render.Renderer())

m.Get("/", func() string {
    return "Test"
})

JaTochNietDan avatar Jun 03 '14 16:06 JaTochNietDan

@JaTochNietDan The symptom you're describing typically happens when there's an error in a handler/middleware outside of gzip's control. I'll double check this to ensure it's still correct as soon as I can.

slogsdon avatar Jun 06 '14 13:06 slogsdon

I just ran into this and fixed it by clearing out my imports for martini, codegangsta and martini-contrib and then doing a fresh go get

Bochenski avatar Jun 06 '14 13:06 Bochenski

I wasn't having the PANIC error that @JaTochNietDan was having, but I am getting gzipped files downloading as well. It's only happening when I a) use gzip, and b) return a status code.

// If I comment this out or remove it, it works perfectly.
m.Use(gzip.All())
m.Group("/x/y/z", func(r martini.Router) {
  r.Get("", SomeFunc)
})
func SomeFunc(req *http.Request, params martini.Params) (int, string) {
  ...
  return 200, "something"
}

lukevers avatar May 04 '15 20:05 lukevers