httpbuf

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 4 Imported by: 2

README

httpbuf

Go Reference

Properly wrap http.ResponseWriter. A simple wrapper around the excellent httpsnoop package that provides slightly better ergonomics.

Install

go get github.com/matthewmueller/httpbuf

Usage

func Middleware(next http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		rw := httpbuf.Wrap(w)
		defer rw.Flush()
		next.ServeHTTP(rw, r)
		fmt.Println("captured", string(rw.Body))
	})
}

Contributors

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResponseWriter

type ResponseWriter struct {
	http.ResponseWriter
	Status  int
	Body    []byte
	Headers http.Header
	// contains filtered or unexported fields
}

func (*ResponseWriter) Flush

func (rw *ResponseWriter) Flush()

func (*ResponseWriter) Hijack added in v0.0.3

func (rw *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)

Hijack flushes any started response before passing control of the connection to the underlying ResponseWriter.

Jump to

Keyboard shortcuts

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