middleware

package
v0.0.0-...-7235347 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2016 License: MIT Imports: 12 Imported by: 49

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BasicRealm = "Authorization Required"

BasicRealm is used when setting the WWW-Authenticate response header.

Functions

func BasicAuth

func BasicAuth(username string, password string) func(http.Handler) http.Handler

Basic returns a Handler that authenticates via Basic Auth. Writes a http.StatusUnauthorized if authentication fails

func BasicAuthFunc

func BasicAuthFunc(authfn func(string, string, *http.Request) bool) func(http.Handler) http.Handler

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

func Buffer() func(http.Handler) http.Handler

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 GorillaLog

func GorillaLog() func(http.Handler) http.Handler

Wraps the Gorilla Logger

func Json

func Json() func(http.Handler) http.Handler

Middleware that sends an application/json header

func NegroniGzip

func NegroniGzip(compression int) func(http.Handler) http.Handler

func NegroniLogrus

func NegroniLogrus() func(http.Handler) http.Handler

func Nosurf

func Nosurf() func(http.Handler) http.Handler

Nosurf is a wrapper for justinas' csrf protection middleware

func SecureCompare

func SecureCompare(given string, actual string) bool

SecureCompare performs a constant time compare of two strings to limit timing attacks.

Types

type User

type User string

User is the authenticated username that was extracted from the request.

Jump to

Keyboard shortcuts

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