Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrLimitReached = xerrors.Errorf("i/o limit reached")
Functions ¶
func RateLimit ¶
func RateLimit(cfg RateLimitConfig) func(http.Handler) http.Handler
RateLimit returns a handler that limits requests based on IP.
func SetBodyLimit ¶
Types ¶
type LimitReader ¶
LimitReader is like io.LimitReader except that it returns ErrLimitReached when the limit has been reached.
func (*LimitReader) Reset ¶
func (l *LimitReader) Reset(n int64)
type LimitedBody ¶
type LimitedBody struct { R *LimitReader // contains filtered or unexported fields }
func (LimitedBody) Close ¶
func (r LimitedBody) Close() error
type RateLimitConfig ¶ added in v0.1.6
type RateLimitConfig struct { Log slog.Logger // Count of the amount of requests allowed in the Window. If the Count is // zero, the rate limiter is disabled. Count int Window time.Duration // RealIPHeader is the header to use to get the real IP address of the // request. If this is empty, the request's RemoteAddr is used. RealIPHeader string }
Click to show internal directories.
Click to hide internal directories.