PleaseStop
A rate limiter plug for Phoenix.
Installation
the package can be installed by adding please_stop
to your list of dependencies in mix.exs
:
def deps do
[
{:please_stop, "~> 0.1.0"}
]
end
Usage
To use PleaseStop
in Phoenix you can use it just like any other plug.
scope "/avatars" do
plug PleaseStop, limit: 5000, ttl: :timer.minutes(1), namespace: :avatars
scope "/something" do
plug PleaseStop, limit: 5, ttl: :timer.minutes(10), namespace: :something
end
end
Options
The options provided to PleaseStop
are detailed below
limit
: The maximum number of requests you’ll accept within the providedttl
.ttl
: The amount of time before the request count is set back to0
. If thelimit
is reached within thisttl
, a429
will be returned and theconn
will be halted.namespace
: The namespace where your rate limiting information is kept.