Documentation ¶
Overview ¶
Package response provides wrapper for http.response.
Index ¶
- type BufferWriter
- func (w *BufferWriter) Buffer() []byte
- func (w *BufferWriter) BufferLength() int
- func (w *BufferWriter) BufferString() string
- func (w *BufferWriter) ClearBuffer()
- func (w *BufferWriter) Flush()
- func (w *BufferWriter) RawWriter() http.ResponseWriter
- func (w *BufferWriter) SetBuffer(data []byte)
- func (w *BufferWriter) Write(data []byte) (int, error)
- func (w *BufferWriter) WriteHeader(status int)
- func (w *BufferWriter) WriteString(data string) (int, error)
- type Writer
- func (w *Writer) BytesWritten() int64
- func (w *Writer) Flush()
- func (w *Writer) Hijack() (conn net.Conn, writer *bufio.ReadWriter, err error)
- func (w *Writer) IsHeaderWrote() bool
- func (w *Writer) IsHijacked() bool
- func (w *Writer) Write(data []byte) (int, error)
- func (w *Writer) WriteHeader(status int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferWriter ¶ added in v2.7.0
type BufferWriter struct { *Writer // The underlying BufferWriter. Status int // HTTP status. // contains filtered or unexported fields }
BufferWriter is the custom writer for http response with buffer.
func NewBufferWriter ¶ added in v2.7.0
func NewBufferWriter(writer http.ResponseWriter) *BufferWriter
func (*BufferWriter) Buffer ¶ added in v2.7.0
func (w *BufferWriter) Buffer() []byte
Buffer returns the buffered content as []byte.
func (*BufferWriter) BufferLength ¶ added in v2.7.0
func (w *BufferWriter) BufferLength() int
BufferLength returns the length of the buffered content.
func (*BufferWriter) BufferString ¶ added in v2.7.0
func (w *BufferWriter) BufferString() string
BufferString returns the buffered content as string.
func (*BufferWriter) ClearBuffer ¶ added in v2.7.0
func (w *BufferWriter) ClearBuffer()
ClearBuffer clears the response buffer.
func (*BufferWriter) Flush ¶ added in v2.7.0
func (w *BufferWriter) Flush()
Flush outputs the buffer to clients and clears the buffer.
func (*BufferWriter) RawWriter ¶ added in v2.7.0
func (w *BufferWriter) RawWriter() http.ResponseWriter
RawWriter returns the underlying BufferWriter.
func (*BufferWriter) SetBuffer ¶ added in v2.7.0
func (w *BufferWriter) SetBuffer(data []byte)
SetBuffer overwrites the buffer with `data`.
func (*BufferWriter) Write ¶ added in v2.7.0
func (w *BufferWriter) Write(data []byte) (int, error)
Write implements the interface function of http.BufferWriter.Write.
func (*BufferWriter) WriteHeader ¶ added in v2.7.0
func (w *BufferWriter) WriteHeader(status int)
WriteHeader implements the interface of http.BufferWriter.WriteHeader.
func (*BufferWriter) WriteString ¶ added in v2.7.0
func (w *BufferWriter) WriteString(data string) (int, error)
WriteString writes string content to internal buffer.
type Writer ¶
type Writer struct { http.ResponseWriter // The underlying ResponseWriter. // contains filtered or unexported fields }
Writer wraps http.ResponseWriter for extra features.
func NewWriter ¶
func NewWriter(writer http.ResponseWriter) *Writer
NewWriter creates and returns a new Writer.
func (*Writer) BytesWritten ¶ added in v2.7.0
BytesWritten returns the length that was written to response.
func (*Writer) IsHeaderWrote ¶
IsHeaderWrote returns if the header status is written.
func (*Writer) IsHijacked ¶
IsHijacked returns if the connection is hijacked.
func (*Writer) Write ¶ added in v2.7.0
Write implements the interface function of http.ResponseWriter.Write.
func (*Writer) WriteHeader ¶
WriteHeader implements the interface of http.ResponseWriter.WriteHeader. Note that the underlying `WriteHeader` can only be called once in a http response.