CheckRateLimit (open)

Implements rate limiting

Syntax

LOADLIB "mod::system/lib/services.whlib";

RECORD FUNCTION CheckRateLimit(RECORD criterium, INTEGER numhits, RECORD options)

Parameters

RECORD criterium

A record describing this rate limit (hashed to generate a unique key), eg an ip address and/or service name

INTEGER numhits

Number of hits to accept in the time period

RECORD options

Options

BOOLEAN exemptdev

Exempt development servers from the ratelimit (if this is a request, add a header to indicate the rate was hit)

INTEGER timeperiod

Time period to which the limit applies in ms. Defaults to 1 minute (60000)

Return value

RECORD

Limit check result

BOOLEAN accepted

If TRUE, accept this request, rate limit not hit

INTEGER backoff

If >0, recommended backoff time before requests will be accepted again (in ms)