middleware

package
v0.0.0-...-e3febf5 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2015 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	// Logger inherits from log.Logger used to log messages with the Logger middleware
	*log.Logger
}

Logger is a middleware handler that logs the request as it goes in and the response as it goes out.

func NewLogger

func NewLogger() *Logger

NewLogger returns a new Logger instance

func (*Logger) ServeHTTP

func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type Recovery

type Recovery struct {
	Logger     *log.Logger
	PrintStack bool
	StackAll   bool
	StackSize  int
}

Recovery is middleware that recovers from any panics and writes a 500 if there was one.

func NewRecovery

func NewRecovery() *Recovery

NewRecovery returns a new instance of Recovery

func (*Recovery) ServeHTTP

func (rec *Recovery) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type Timeout

type Timeout struct {
	Limit time.Duration
}

Timeout middleware panics if the request hasn't completed after the time limit

func NewTimeout

func NewTimeout(limit time.Duration) *Timeout

NewTimeout builds a new timeout middleware

func (*Timeout) ServeHTTP

func (m *Timeout) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

Jump to

Keyboard shortcuts

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