middleware

package
v2.0.12+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Logger is a middleware that logs requests, along with request URI, HTTP status code, handler return value and request timing

Functions

func Default

func Default(mws ...noodle.Middleware) noodle.Chain

Default is a convenience function creating new noodle.Chain with Logger, Recover and LocalStore middlewares

func GetRealIP

func GetRealIP(r *http.Request) string

GetRealIP extracts real client IP from handler context

func GetStore

func GetStore(r *http.Request) *store.Store

GetStore extracts common store from context

func GetUser

func GetUser(r *http.Request) string

GetUser extract authentication information from context

func HTTPAuth

func HTTPAuth(realm string, authFunc func(username, password string) bool) noodle.Middleware

HTTPAuth is a middleware factory function that accepts the authentication realm and function for username and password verification. Resulting middleware injects username into request context if authentication successful.

func LocalStore

func LocalStore(next http.HandlerFunc) http.HandlerFunc

LocalStore is a middleware that injects common data store into request context

func NewLogger

func NewLogger(f func(string, ...interface{})) noodle.Middleware

NewLogger constructs logger with arbitrary output function

func RealIP

func RealIP(next http.HandlerFunc) http.HandlerFunc

RealIP is a middleware that injects client IP parsed from request headers into context

func Recover

func Recover(f func(http.ResponseWriter, *http.Request, error)) noodle.Middleware

Recover is a basic middleware that catches panics and passes them to the pre-defined error handler func

Types

type RecoverError

type RecoverError struct {
	Value      interface{}
	StackTrace []byte
}

RecoverError contains the original error value and a stack trace

func (RecoverError) Error

func (r RecoverError) Error() string

func (RecoverError) Format

func (r RecoverError) Format(s fmt.State, verb rune)

Format implements Formatter interface

Jump to

Keyboard shortcuts

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