Documentation
¶
Overview ¶
Package middleware is a collection of useful middleware which is compatible with net/http's Handler interface
Index ¶
- Variables
- func BasicAuth(username string, password string) func(http.Handler) http.Handler
- func BasicAuthFunc(authfn func(string, string, *http.Request) bool) func(http.Handler) http.Handler
- func Buffer() func(http.Handler) http.Handler
- func GorillaLog() func(http.Handler) http.Handler
- func Json() func(http.Handler) http.Handler
- func MaxAgeHandler(seconds int, h http.Handler) http.Handler
- func NegroniGzip(compression int) func(http.Handler) http.Handler
- func NegroniLogrus() func(http.Handler) http.Handler
- func NoPanic(next http.Handler) http.Handler
- func Nosurf() func(http.Handler) http.Handler
- func SecureCompare(given string, actual string) bool
- type User
Constants ¶
This section is empty.
Variables ¶
var BasicRealm = "Authorization Required"
BasicRealm is used when setting the WWW-Authenticate response header.
Functions ¶
func BasicAuth ¶
Basic returns a Handler that authenticates via Basic Auth. Writes a http.StatusUnauthorized if authentication fails
func BasicAuthFunc ¶
BasicAuthFunc returns a Handler that authenticates via Basic Auth using the provided function. The function should return true for a valid username/password combination.
func Buffer ¶
Middleware that buffers all http output. This permits output to be written before headers are sent. Downside: no output is sent until it's all ready to be sent, so this breaks streaming.
Note: currently ignores errors
func MaxAgeHandler ¶
MaxAgeHandler sets a cache header to indicate when a resource should expire. Taken from https://groups.google.com/forum/#!topic/golang-nuts/n-GjwsDlRco
func NoPanic ¶
NoPanic permits recovery from panics which occur during a request, so that errors which occur during a request do not bring down the server. from http://nicolasmerouze.com/middlewares-golang-best-practices-examples/
func SecureCompare ¶
SecureCompare performs a constant time compare of two strings to limit timing attacks.