middleware

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithContext

func WithContext(ctx context.Context, h http.Handler) http.Handler

WithContext set the context on the request.

func WithRecovery

func WithRecovery(h http.Handler) http.Handler

WithRecovery recovers from panics and log the error.

func WithRequestStats

func WithRequestStats(h http.Handler) http.Handler

WithRequestStats collects statistics about the request.

func WithResponseTime

func WithResponseTime(h http.Handler) http.Handler

WithResponseTime reports the response time.

Types

type Recovery

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

Recovery is a middleware that will recover from panics and logs the error.

func (Recovery) ServeHTTP

func (m Recovery) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves the request.

type ResponseWriter

type ResponseWriter interface {
	http.ResponseWriter

	// Status returns the status code of the response or 0 if the response has
	// not be written.
	Status() int
}

ResponseWriter is a wrapper around http.ResponseWriter that provides extra information about the response.

func NewResponseWriter

func NewResponseWriter(rw http.ResponseWriter) ResponseWriter

NewResponseWriter create a new ResponseWriter.

Jump to

Keyboard shortcuts

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