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: 1 module, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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