rate_limiting v0.1.3 RateLimiting View Source

A rate limiting plugin that validates whether source IP address is allowed to make a connection.

Link to this section Summary

Functions

Checks whether source ip address is allowed to make request based on max requests count within a minute. Assumes that input is of IPv4 format, 1.2.3.4.

Link to this section Functions

Link to this function

allow?(source_ip_address)

View Source

Checks whether source ip address is allowed to make request based on max requests count within a minute. Assumes that input is of IPv4 format, 1.2.3.4.

Examples

iex> RateLimiting.allow?("1.2.3.4")
{:error, response} ->
  %RateLimiting.Config{
    interval_seconds: 60,
    max_requests: 100,
    time_request_made: %Time{},
    response_code: 429,
    response_message: "Rate limit exceeded. Try again in 60 seconds.",
    source_ip_address: "1.2.3.4"
    valid? false
  }