Refactors response_writer.go

This commit is contained in:
Manu Mtz-Almeida 2015-03-23 04:45:33 +01:00
parent 251b73fc70
commit 34b1d0262e
1 changed files with 5 additions and 8 deletions

View File

@ -6,14 +6,14 @@ package gin
import ( import (
"bufio" "bufio"
"errors"
"log" "log"
"net" "net"
"net/http" "net/http"
) )
const ( const (
NoWritten = -1 NoWritten = -1
DefaultStatus = 200
) )
type ( type (
@ -31,15 +31,15 @@ type (
responseWriter struct { responseWriter struct {
http.ResponseWriter http.ResponseWriter
status int
size int size int
status int
} }
) )
func (w *responseWriter) reset(writer http.ResponseWriter) { func (w *responseWriter) reset(writer http.ResponseWriter) {
w.ResponseWriter = writer w.ResponseWriter = writer
w.status = 200
w.size = NoWritten w.size = NoWritten
w.status = DefaultStatus
} }
func (w *responseWriter) WriteHeader(code int) { func (w *responseWriter) WriteHeader(code int) {
@ -90,8 +90,5 @@ func (w *responseWriter) CloseNotify() <-chan bool {
// Implements the http.Flush interface // Implements the http.Flush interface
func (w *responseWriter) Flush() { func (w *responseWriter) Flush() {
flusher, ok := w.ResponseWriter.(http.Flusher) w.ResponseWriter.(http.Flusher).Flush()
if ok {
flusher.Flush()
}
} }