Documentation ¶
Index ¶
- Variables
- func Default(mws ...noodle.Middleware) noodle.Chain
- func GetRealIP(r *http.Request) string
- func GetStore(r *http.Request) *store.Store
- func GetUser(r *http.Request) string
- func HTTPAuth(realm string, authFunc func(username, password string) bool) noodle.Middleware
- func LocalStore(next http.HandlerFunc) http.HandlerFunc
- func NewLogger(f func(string, ...interface{})) noodle.Middleware
- func RealIP(next http.HandlerFunc) http.HandlerFunc
- func Recover(f func(http.ResponseWriter, *http.Request, error)) noodle.Middleware
- type RecoverError
Constants ¶
This section is empty.
Variables ¶
var Logger = NewLogger(log.Printf)
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 HTTPAuth ¶
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
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