middleware

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package middleware implements reusable HTTP middleware.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultTags

func DefaultTags(r *http.Request) []string

DefaultTags extracts the method and path from the request.

func WithRecovery

func WithRecovery(h http.Handler, lable log.Loggable) http.Handler

WithRecovery recovers from panics and log the error.

func WithRequestStats

func WithRequestStats(h http.Handler, sable stats.Statable, fns ...TagsFunc) http.Handler

WithRequestStats collects statistics about the request.

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

	// BytesWritten returns the number of bytes written to the writer.
	BytesWritten() int64
}

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.

type TagsFunc

type TagsFunc func(*http.Request) []string

TagsFunc returns a set of tags from a request.

Jump to

Keyboard shortcuts

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