Configuration

class Configuration(val storage: Storage)

Configuration holder for the RateLimit feature.

Constructors

Link copied to clipboard
constructor(storage: Storage)

Functions

Link copied to clipboard
fun alwaysAllow(block: (String) -> Boolean)

Override the handler to always allow a host. Returns true, if the host should be allowed. The default value is false.

Link copied to clipboard
fun alwaysBlock(block: (String) -> Boolean)

Override the handler to always block a host. Returns true, if the host should be blocked. The default value is false.

Link copied to clipboard
fun host(block: (ApplicationCall) -> String)

Override the handler to return the unique host information from a ApplicationCall. By default, the RequestConnectionPoint.remoteHost is used.

Link copied to clipboard
fun skip(block: (ApplicationCall) -> SkipResult)

Overrides the handler to skip a call from the rate limit check. Return SkipResult.SkipRateLimit, if the call should be skipped. Default value is SkipResult.ExecuteRateLimit, every call will be checked.

Properties

Link copied to clipboard

When true, this plugin does not check if CORS is applied before this plugin to prevent limiting CORS requests.

Link copied to clipboard
var limit: Int

The number of allowed requests until the request will be blocked. Default value is 1000.

Link copied to clipboard

Add the HttpHeaders.RetryAfter header to the response, if the host is blocked by the rate limit check or by the alwaysBlock function. The default value is true.

Link copied to clipboard
Link copied to clipboard

The duration until a blocked request will be allowed. Default value is 1 hour.