From 34b1d0262e373e9eb98fde5534b8290bf1b2ebd7 Mon Sep 17 00:00:00 2001 From: Manu Mtz-Almeida Date: Mon, 23 Mar 2015 04:45:33 +0100 Subject: [PATCH] Refactors response_writer.go --- response_writer.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/response_writer.go b/response_writer.go index a8cd775b..269ab1bf 100644 --- a/response_writer.go +++ b/response_writer.go @@ -6,14 +6,14 @@ package gin import ( "bufio" - "errors" "log" "net" "net/http" ) const ( - NoWritten = -1 + NoWritten = -1 + DefaultStatus = 200 ) type ( @@ -31,15 +31,15 @@ type ( responseWriter struct { http.ResponseWriter - status int size int + status int } ) func (w *responseWriter) reset(writer http.ResponseWriter) { w.ResponseWriter = writer - w.status = 200 w.size = NoWritten + w.status = DefaultStatus } func (w *responseWriter) WriteHeader(code int) { @@ -90,8 +90,5 @@ func (w *responseWriter) CloseNotify() <-chan bool { // Implements the http.Flush interface func (w *responseWriter) Flush() { - flusher, ok := w.ResponseWriter.(http.Flusher) - if ok { - flusher.Flush() - } + w.ResponseWriter.(http.Flusher).Flush() }