mirror of
https://github.com/benbusby/farside.git
synced 2025-04-20 10:58:42 +00:00
Fix formatting
This commit is contained in:
parent
3181bdfc80
commit
fec966ae59
3 changed files with 8 additions and 5 deletions
|
@ -4,9 +4,11 @@ defmodule Farside.Throttle do
|
||||||
|
|
||||||
rule "throttle per ip", conn do
|
rule "throttle per ip", conn do
|
||||||
# throttle to 1 request per second
|
# throttle to 1 request per second
|
||||||
throttle conn.remote_ip,
|
throttle(conn.remote_ip,
|
||||||
period: 1_000, limit: 1,
|
period: 1_000,
|
||||||
|
limit: 1,
|
||||||
storage: {PlugAttack.Storage.Ets, Farside.Throttle.Storage}
|
storage: {PlugAttack.Storage.Ets, Farside.Throttle.Storage}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def allow_action(conn, _data, _opts), do: conn
|
def allow_action(conn, _data, _opts), do: conn
|
||||||
|
|
2
mix.exs
2
mix.exs
|
@ -27,7 +27,7 @@ defmodule Farside.MixProject do
|
||||||
{:plug_attack, "~> 0.4.2"},
|
{:plug_attack, "~> 0.4.2"},
|
||||||
{:plug_cowboy, "~> 2.0"},
|
{:plug_cowboy, "~> 2.0"},
|
||||||
{:poison, "~> 5.0"},
|
{:poison, "~> 5.0"},
|
||||||
{:redix, "~> 1.1"},
|
{:redix, "~> 1.1"}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,7 @@ defmodule FarsideTest do
|
||||||
|
|
||||||
def test_conn(path) do
|
def test_conn(path) do
|
||||||
:timer.sleep(1000)
|
:timer.sleep(1000)
|
||||||
|
|
||||||
:get
|
:get
|
||||||
|> conn(path, "")
|
|> conn(path, "")
|
||||||
|> Router.call(@opts)
|
|> Router.call(@opts)
|
||||||
|
|
Loading…
Add table
Reference in a new issue