go-chi / httprate

net/http rate limiter middleware
MIT License
270 stars 18 forks source link

Export http.RateLimiter type #43

Closed VojtechVitek closed 2 months ago

VojtechVitek commented 2 months ago

So users can pass *http.RateLimiter (or save in their server struct) and use the new .OnLimit() feature from https://github.com/go-chi/httprate/pull/42.

github-actions[bot] commented 2 months ago

Benchmark Results

goos: linux
goarch: amd64
pkg: github.com/go-chi/httprate
cpu: AMD EPYC 7763 64-Core Processor                
               │ master.txt  │            pr.txt             │
               │   sec/op    │   sec/op     vs base          │
LocalCounter-4   19.54m ± 1%   19.57m ± 1%  ~ (p=0.190 n=10)

               │  master.txt  │             pr.txt             │
               │     B/op     │     B/op      vs base          │
LocalCounter-4   2.834Mi ± 0%   2.832Mi ± 0%  ~ (p=0.529 n=10)

               │ master.txt  │            pr.txt             │
               │  allocs/op  │  allocs/op   vs base          │
LocalCounter-4   121.5k ± 0%   121.4k ± 0%  ~ (p=0.565 n=10)