response

package
v2.8.0-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package response provides wrapper for http.response.

Index

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

func (w *Writer) BytesWritten() int64

BytesWritten returns the length that was written to response.

func (*Writer) Flush

func (w *Writer) Flush()

Flush sends any buffered data to the client.

func (*Writer) Hijack

func (w *Writer) Hijack() (conn net.Conn, writer *bufio.ReadWriter, err error)

Hijack implements the interface function of http.Hijacker.Hijack.

func (*Writer) IsHeaderWrote

func (w *Writer) IsHeaderWrote() bool

IsHeaderWrote returns if the header status is written.

func (*Writer) IsHijacked

func (w *Writer) IsHijacked() bool

IsHijacked returns if the connection is hijacked.

func (*Writer) Write added in v2.7.0

func (w *Writer) Write(data []byte) (int, error)

Write implements the interface function of http.ResponseWriter.Write.

func (*Writer) WriteHeader

func (w *Writer) WriteHeader(status int)

WriteHeader implements the interface of http.ResponseWriter.WriteHeader. Note that the underlying `WriteHeader` can only be called once in a http response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL