Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PassthroughWriter ¶
type PassthroughWriter struct {
http.ResponseWriter
}
PassthroughWriter wraps an http.ResponseWriter and preserves optional interfaces like Hijacker, Flusher, and Pusher by delegating to the underlying ResponseWriter if it supports them.
This is the standard pattern for Go middleware that needs to wrap ResponseWriter while maintaining support for protocol upgrades (WebSocket), streaming (Flusher), and HTTP/2 server push.
func New ¶
func New(w http.ResponseWriter) *PassthroughWriter
New creates a new wrapper around the given ResponseWriter.
func (*PassthroughWriter) Flush ¶
func (w *PassthroughWriter) Flush()
Flush implements http.Flusher interface if the underlying ResponseWriter supports it.
func (*PassthroughWriter) Hijack ¶
func (w *PassthroughWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
Hijack implements http.Hijacker interface if the underlying ResponseWriter supports it. This is required for WebSocket connections and other protocol upgrades.
func (*PassthroughWriter) Push ¶
func (w *PassthroughWriter) Push(target string, opts *http.PushOptions) error
Push implements http.Pusher interface if the underlying ResponseWriter supports it.
func (*PassthroughWriter) Unwrap ¶
func (w *PassthroughWriter) Unwrap() http.ResponseWriter
Unwrap returns the underlying ResponseWriter. This is required for http.ResponseController (Go 1.20+) to work correctly.