Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Wrap ¶
func Wrap(w http.ResponseWriter, hooks Hooks) http.ResponseWriter
Wrap returns a wrapped version of w that provides the exact same interface as w. Specifically if w implements any combination of http.Hijacker, http.Flusher, http.CloseNotifier or io.ReaderFrom, the wrapped version will implement the exact same combination. If no hooks are set, the wrapped version also behaves exactly as w. Hooks targeting methods not supported by w are ignored. Any other hooks will intercept the method they target and may modify the call's arguments and/or return values. The CaptureMetrics implementation serves as a working example for how the hooks can be used.
Types ¶
type CloseNotifyFunc ¶
type CloseNotifyFunc func() <-chan bool
CloseNotifyFunc is part of the http.CloseNotifier interface.
type HeaderFunc ¶
HeaderFunc is part of the http.ResponseWriter interface.
type HijackFunc ¶
type HijackFunc func() (net.Conn, *bufio.ReadWriter, error)
HijackFunc is part of the http.Hijacker interface.
type Hooks ¶
type Hooks struct { Header func(HeaderFunc) HeaderFunc Write func(WriteFunc) WriteFunc WriteHeader func(WriteHeaderFunc) WriteHeaderFunc Flush func(FlushFunc) FlushFunc CloseNotify func(CloseNotifyFunc) CloseNotifyFunc ReadFrom func(ReadFromFunc) ReadFromFunc Hijack func(HijackFunc) HijackFunc }
Hooks defines a set of method interceptors for methods included in http.ResponseWriter as well as some others. You can think of them as middleware for the function calls they target. See Wrap for more details.
type ReadFromFunc ¶
ReadFromFunc is part of the io.ReaderFrom interface.
type WriteHeaderFunc ¶
type WriteHeaderFunc func(int)
WriteHeaderFunc is part of the http.ResponseWriter interface.