go-martini / martini

Classy web framework for Go
martini.codegangsta.io
MIT License
11.63k stars 1.1k forks source link

Properly support closenotifier #398

Closed umcodemonkey closed 8 years ago

umcodemonkey commented 8 years ago

According to the golang docs:

The CloseNotifier interface is implemented by ResponseWriters which allow detecting when the underlying connection has gone away.

This appears to be an optional interface of ResponseWriter, but martini is treating it as if it's always available. In this change, the function that constructs the martini ResponseWriter wrapper checks to see if the provided http.ResponseWriter implements the CloseNotifier interface. If it does, then the returned wrapper will implement CloseNotifier as a pass-through.