httpbuf

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 2 Imported by: 1

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()

Jump to

Keyboard shortcuts

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