Documentation
¶
Overview ¶
Package response_writer provides legacy JSON response helpers. EXPERIMENTAL: This package is not yet API-stable.
Index ¶
- func WriteErr(w http.ResponseWriter, code int, msg string)
- func WriteJSON(w http.ResponseWriter, code int, v any)
- type Capture
- type Writer
- func (w *Writer) BytesWritten() int
- func (w *Writer) Flush()
- func (w *Writer) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (w *Writer) Push(target string, opts *http.PushOptions) error
- func (w *Writer) ReadFrom(r io.Reader) (int64, error)
- func (w *Writer) Status() int
- func (w *Writer) Unwrap() http.ResponseWriter
- func (w *Writer) Write(b []byte) (int, error)
- func (w *Writer) WriteHeader(code int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Capture ¶
type Capture struct {
// contains filtered or unexported fields
}
Capture buffers response headers and body for later replay.
func (*Capture) BytesWritten ¶
BytesWritten returns the number of buffered bytes.
func (*Capture) WriteHeader ¶
WriteHeader records the status code without writing.
func (*Capture) WriteTo ¶
func (c *Capture) WriteTo(w http.ResponseWriter)
WriteTo writes the buffered response to the provided ResponseWriter.
type Writer ¶
type Writer struct {
http.ResponseWriter
// contains filtered or unexported fields
}
Writer wraps an http.ResponseWriter and tracks status/bytes. It forwards optional interfaces (Flusher, Hijacker, Pusher, ReaderFrom).
func Wrap ¶
func Wrap(w http.ResponseWriter) *Writer
Wrap returns a response writer wrapper that tracks status and bytes.
func (*Writer) BytesWritten ¶
BytesWritten returns the number of bytes written.
func (*Writer) Push ¶
func (w *Writer) Push(target string, opts *http.PushOptions) error
Push forwards server push if supported.
func (*Writer) Unwrap ¶
func (w *Writer) Unwrap() http.ResponseWriter
Unwrap returns the underlying http.ResponseWriter.
func (*Writer) WriteHeader ¶
WriteHeader captures the status code and forwards to the underlying writer.