Registry / web-framework / ulule-limiter-v3

ulule-limiter-v3

JSON →
library3.11.2gogounverified

Rate limiting middleware for HTTP applications with support for various storage backends.

go get github.com/ulule/limiter/v3
INSTALL
IMPORT
SIG · ULULE-LIMITER-V3
U
ulule-limiter-v3
web-frameworkgov3.11.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

limiter
✓ github.com/ulule/limiter/v3

Rate limit HTTP requests using in-memory store

package main import ( "net/http" "github.com/ulule/limiter/v3" "github.com/ulule/limiter/v3/drivers/store/memory" ) func main() { rate := limiter.Rate{ Period: 1 * time.Second, Limit: 10, } store := memory.NewStore() instance := limiter.New(store, rate) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { ctx, err := instance.Get(r.Context(), r.RemoteAddr) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } if ctx.Reached { http.Error(w, "Rate limit exceeded", http.StatusTooManyRequests) return } w.Write([]byte("OK")) }) http.ListenAndServe(":8080", nil) }
Debug
Known issues

No known issues recorded.

Upgrade
Version history
3.11.2latest on pkg.go.dev
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
ulule-limiter-v3 — go get ulule-limiter-v3 · libregistry