Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 577 Bytes

README.md

File metadata and controls

26 lines (20 loc) · 577 Bytes

reili

A simple but general purpose http Rate Limiter

Installing

$ go get -u github.com/mzampetakis/reili

Usage

Define your own identifier function

IdentifyVisitor(r *http.Request) (string, error)

following the interface that package reili provides

type VisitorIdentifier interface {
	IdentifyVisitor(r *http.Request) (string, error)
}

Create a rate limiter using reili.NewRateLimiter(reqPerSec, burstReq, visitorIdentifier) and then limit your server's mux using your limiter.

Examples

Limit by request IP