middleware

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capture added in v1.4.0

type Capture struct {
	// contains filtered or unexported fields
}

func CaptureResponse added in v1.4.0

func CaptureResponse(w http.ResponseWriter, r *http.Request, next http.Handler) *Capture

CaptureResponse runs the given http.Handler and returns the captured response. To see headers, look at `w.Header()`, which will be mutated by the handler.

func NewCapture added in v1.4.0

func NewCapture() *Capture

NewCapture creates a ready-to-use Capture. You use it by calling `Wrap` on an `http.ResponseWriter`, using the result in a handler, then examining the capture StatusCode() and Body(). The convenience `CaptureResponse(...)` below does the above given the http.Handler, and hands you back the capture.

func (*Capture) Body added in v1.4.0

func (c *Capture) Body() *bytes.Buffer

func (*Capture) StatusCode added in v1.4.0

func (c *Capture) StatusCode() int

func (*Capture) Wrap added in v1.4.0

Wrap creates a http.ResponseWriter which will capture the response in the method receiver so it can be examined after being used in a handler. Consider using `CaptureResponse()`, which does this for you.

type LoggingResponseWriter

type LoggingResponseWriter struct {
	http.ResponseWriter
	*Capture
}

LoggingResponseWriter wraps a ResponseWriter in such a way that the response status code, body and headers can be examined after its been used to serve a response. This is deprecated: use Capture.Wrap(w) instead, because it wraps the ResponseWriter such that additional interfaces (e.g., io.ReaderFrom) that may be present on the supplied ResponseWriter are still supported in the wrapper.

func NewLoggingResponseWriter

func NewLoggingResponseWriter(next http.ResponseWriter) *LoggingResponseWriter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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