Implements Redis support for chi-ratelimit
I wanted to keep chi-ratelimit without any dependencies, so this was the only solution. If only Go had support for peer-dependencies like NPM. 🥺
$ go get github.com/noelware/chi-ratelimit/redis
package main
import (
"net/http"
"github.com/go-chi/chi/v5"
"github.com/noelware/chi-ratelimit"
)
func main() {
ratelimiter := ratelimiter.NewRatelimiter(
ratelimiter.WithProvider(redis.New(
redis.WithKeyPrefix("owo:"),
redis.WithClient(<redis client here>),
)),
)
router := chi.NewRouter()
router.Use(ratelimiter.Middleware)
router.Get("/", func (w http.ResponseWriter, req *http.Request) {
// do stuff here
})
http.ListenAndServe(":3030", router)
}
chi-ratelimit-redis is released under the MIT License by Noelware.