From 8f1bbc6b6a3faf0776cc8313a6432565bd6eb559 Mon Sep 17 00:00:00 2001 From: Manu Mtz-Almeida Date: Tue, 26 Aug 2014 17:52:58 +0200 Subject: [PATCH] gin.responseWriter implements http.Flusher and http.CloseNotifier --- response_writer.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/response_writer.go b/response_writer.go index 0def5d07..2a21e578 100644 --- a/response_writer.go +++ b/response_writer.go @@ -12,6 +12,9 @@ type ( ResponseWriter interface { http.ResponseWriter http.Hijacker + http.Flusher + http.CloseNotifier + Status() int Written() bool WriteHeaderNow() @@ -67,3 +70,16 @@ func (w *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { } return hijacker.Hijack() } + +// Implements the http.CloseNotify interface +func (w *responseWriter) CloseNotify() <-chan bool { + return w.ResponseWriter.(http.CloseNotifier).CloseNotify() +} + +// Implements the http.Flush interface +func (w *responseWriter) Flush() { + flusher, ok := w.ResponseWriter.(http.Flusher) + if ok { + flusher.Flush() + } +}