From 6a7b777f1453011f42cdb318f3ffb23c39655e48 Mon Sep 17 00:00:00 2001 From: Matt Holt Date: Sat, 9 Apr 2016 22:11:36 -0600 Subject: [PATCH] panic if not a Flusher Caddy recovers panics that occur in the middleware stack so this is not a risk to process termination. This way is also preferable to hiding the error. See https://github.com/mholt/caddy/commit/3faad41b437c48cea37863123fab425169bc0c6e#commitcomment-17035158 --- middleware/recorder.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/middleware/recorder.go b/middleware/recorder.go index 44d277365..ab30e3053 100644 --- a/middleware/recorder.go +++ b/middleware/recorder.go @@ -83,5 +83,7 @@ func (r *ResponseRecorder) Hijack() (net.Conn, *bufio.ReadWriter, error) { func (r *ResponseRecorder) Flush() { if f, ok := r.ResponseWriter.(http.Flusher); ok { f.Flush() + } else { + panic("not a Flusher") // should be recovered at the beginning of middleware stack } }