From fa8162450a343a72d44a6e0736bcb7c10458ce01 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 20 Jun 2018 11:30:40 +0800 Subject: [PATCH] chore: ResponseWriter rename responseWriterBase --- response_writer.go | 23 +++++++++++++++++++++++ response_writer_1.7.go | 23 +---------------------- response_writer_1.8.go | 22 +--------------------- 3 files changed, 25 insertions(+), 43 deletions(-) diff --git a/response_writer.go b/response_writer.go index 2c97e76631..14b1cfc38a 100644 --- a/response_writer.go +++ b/response_writer.go @@ -16,6 +16,29 @@ const ( defaultStatus = 200 ) +type responseWriterBase interface { + http.ResponseWriter + http.Hijacker + http.Flusher + http.CloseNotifier + + // Returns the HTTP response status code of the current request. + Status() int + + // Returns the number of bytes already written into the response http body. + // See Written() + Size() int + + // Writes the string into the response body. + WriteString(string) (int, error) + + // Returns true if the response body was already written. + Written() bool + + // Forces to write the http header (status code + headers). + WriteHeaderNow() +} + type responseWriter struct { http.ResponseWriter size int diff --git a/response_writer_1.7.go b/response_writer_1.7.go index fd0c2b7ea1..801d196b09 100644 --- a/response_writer_1.7.go +++ b/response_writer_1.7.go @@ -6,28 +6,7 @@ package gin -import "net/http" - // ResponseWriter ... type ResponseWriter interface { - http.ResponseWriter - http.Hijacker - http.Flusher - http.CloseNotifier - - // Returns the HTTP response status code of the current request. - Status() int - - // Returns the number of bytes already written into the response http body. - // See Written() - Size() int - - // Writes the string into the response body. - WriteString(string) (int, error) - - // Returns true if the response body was already written. - Written() bool - - // Forces to write the http header (status code + headers). - WriteHeaderNow() + responseWriterBase } diff --git a/response_writer_1.8.go b/response_writer_1.8.go index 5f38645ca6..527c00383a 100644 --- a/response_writer_1.8.go +++ b/response_writer_1.8.go @@ -12,27 +12,7 @@ import ( // ResponseWriter ... type ResponseWriter interface { - http.ResponseWriter - http.Hijacker - http.Flusher - http.CloseNotifier - - // Returns the HTTP response status code of the current request. - Status() int - - // Returns the number of bytes already written into the response http body. - // See Written() - Size() int - - // Writes the string into the response body. - WriteString(string) (int, error) - - // Returns true if the response body was already written. - Written() bool - - // Forces to write the http header (status code + headers). - WriteHeaderNow() - + responseWriterBase // get the http.Pusher for server push Pusher() http.Pusher }