Help us shape the future of Go! Take the 2026 Go Developer Survey

middleware

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2021 License: MIT Imports: 4 Imported by: 0

README

middleware Build Status

Useful middlewares for Pipes library.

What's in the box?

Context middleware

Creates request Context and passes it forward.

Panic recovery middleware

Handles panic and allows to provide user friendly message or redirect to error page using http.ResponseWriter.

Rate limiter middleware (NOT TESTED IN PRODUCTION)

Limits network requests from single IP using provided time function.

Decodes user object from requests cookie and adds to context

Documentation

Index

Constants

View Source
const User = pipes.ContextKey("User")

User context key

Variables

This section is empty.

Functions

func AddOptions added in v1.0.1

func AddOptions(options map[interface{}]interface{}) pipes.Middleware

AddOptions adds context options

func Context

func Context(ctx context.Context, w http.ResponseWriter, r *http.Request, next pipes.Next)

Context adds context to the request pipeline

func CookieAuth

func CookieAuth(authCookieName string, cookieDec cookieDecoder, userFac userFactory) pipes.Middleware

CookieAuth creates cookie auth middleware.

func LimitPerMinute

func LimitPerMinute(t time.Time) time.Time

LimitPerMinute round time to a minute

func LimitRate

func LimitRate(timeFun func(time.Time) time.Time, limit int) pipes.Middleware

LimitRate creates rate limitter middleware using provided time bucketing function

func PanicHandler

func PanicHandler(handler func(ctx context.Context, w http.ResponseWriter, r *http.Request, err interface{})) pipes.Middleware

PanicHandler creates middleware which recovers from panic in the pipeline and can return user friedly message or page. Should be added as early as possible in the pipeline to handle panics from other middlewares.

Types

This section is empty.

Jump to

Keyboard shortcuts

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