middleware

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2016 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Common

func Common(h httpx.Handler) httpx.Handler

Common wraps the handler with common middleware to:

* Log requests * Recover from panics. * Add the request id to the context.

func Handler added in v0.10.1

func Handler(root context.Context, h httpx.Handler) http.Handler

Handler adapts an httpx.Handler to an http.Handler using the provided root context.

func LogRequests added in v0.10.1

func LogRequests(h httpx.Handler) httpx.Handler

LogRequests logs the requests to the embedded logger.

func PrefixRequestID added in v0.10.1

func PrefixRequestID(h httpx.Handler) httpx.Handler

PrefixRequestID adds the request as a prefix to the log15.Logger.

func WithRequest added in v0.10.1

func WithRequest(h httpx.Handler) httpx.Handler

WithRequest adds information about the http.Request to reported errors.

Types

type Recovery added in v0.10.1

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

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

func WithRecovery added in v0.10.1

func WithRecovery(h httpx.Handler) *Recovery

func (*Recovery) ServeHTTPContext added in v0.10.1

func (h *Recovery) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) (err error)

ServeHTTPContext implements the httpx.Handler interface. It recovers from panics and returns an error for upstream middleware to handle.

Jump to

Keyboard shortcuts

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