chore: ResponseWriter rename responseWriterBase

This commit is contained in:
Bo-Yi Wu 2018-06-20 11:30:40 +08:00
parent 28a6d2bbf6
commit 8ed5d8bd3d
3 changed files with 25 additions and 43 deletions

View File

@ -16,6 +16,29 @@ const (
defaultStatus = 200 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 { type responseWriter struct {
http.ResponseWriter http.ResponseWriter
size int size int

View File

@ -6,28 +6,7 @@
package gin package gin
import "net/http"
// ResponseWriter ... // ResponseWriter ...
type ResponseWriter interface { type ResponseWriter interface {
http.ResponseWriter responseWriterBase
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()
} }

View File

@ -12,27 +12,7 @@ import (
// ResponseWriter ... // ResponseWriter ...
type ResponseWriter interface { type ResponseWriter interface {
http.ResponseWriter responseWriterBase
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()
// get the http.Pusher for server push // get the http.Pusher for server push
Pusher() http.Pusher Pusher() http.Pusher
} }