Categorygithub.com/utsavanand2/rate-limiter
modulepackage
0.0.4
Repository: https://github.com/utsavanand2/rate-limiter.git
Documentation: pkg.go.dev

# README

rate-limiter

A Golang http rate-limiter which uses Redis. (Future implementations would include more approaches to rate limiting)

Inspired by https://github.com/mauricio/redis-rate-limiter

# Functions

No description provided by the author
NewHTTPHeadersExtractor creates a new HTTP header extractor.
NewHTTPRateLimiterHandler wraps an existing http.Handler object performing rate limiting before sending the request to the wrapped handler.

# Constants

No description provided by the author
No description provided by the author

# Structs

RateLimiterConfig holds the basic config we need to create a middleware http.Handler object that performs rate limiting before offloading the request to an actual handler.
Request defines a request that needs to be evaluated against the ratelimiter.
Result represents the response to a check if a client should be rate limited or not.

# Interfaces

Extractor represents the way we will extract a key from an HTTPRequest, this could be a value from a header, request path, method used, user authentication information, any information that is available at the HTTP request that wouldn't cause side effects if it was collected (this object shouldn't read the body of the request).
Strategy is the interface the rate limit implementations must implement to be used, it takes a `Request` and returns a `Result` and an `error`, any errors the rate-limiter finds should be bubbled up so the code can make a decision about what it wants to do with the request.

# Type aliases

State is the result of evaluating the rate limit, either `Deny` or `Allow` a request.