ratelimit

package
v0.0.0-...-263c4a3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2017 License: LGPL-3.0 Imports: 9 Imported by: 1

Documentation

Overview

Package ratelimit manages rate limits for urls.

It can be used instead of captchas, since breaking captchas is a commercial service, yielding a captcha to be nothing more than a rate limit.

The rate limited requests for each client (ip address) are stored in the database, and subsequent requests from the same client are denied if they come within the set time window.

Entries of non-returning clients are cleared from the database regularly.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTooManyRequests = errors.New("ErrTooManyRequests")
	ErrInvalidRequest  = errors.New("ErrInvalidRequest")
)

Functions

func Handle

func Handle(handle httprouter.Handle, opt_seconds ...int) httprouter.Handle

ratelimit.Handle returns a httprouter.Handle that denies a request if it's repeated from the same client within the given number of seconds, or handles it, and resets the time window. Passing 0 seconds bypasses the rate limit.

Default limit is read from the RATELIMIT environment variable. The default value for RATELIMIT is 60 seconds.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL