Hammer Plug Save

A plug to apply rate-limiting with Hammer

Project README

Hammer.Plug

Build Status Hex.pm Documentation Total Download License

Hammer is a rate-limiter for Elixir, with pluggable storage backends.

This library is a plug helper, to easily add rate-limiting to Phoenix applications, or any Elixir system that uses plug.

Example:

# Allow ten uploads per 60 seconds
plug Hammer.Plug, [
  rate_limit: {"video:upload", 60_000, 10},
  by: {:session, :user_id}
] when action == :upload_video_file

def upload_video_file(conn, _opts) do
  # ...
end

Documentation

See the Hammer documentation page for more info on Hammer itself.

See the Hammer.Plug docs for more info about this library and how to use it, specifically the Hammer.Plug module.

Installation

Hammer-Plug is avaliable available in Hex, the package can be installed by adding hammer_plug to your list of dependencies in mix.exs:

def deps do
  [
    {:hammer, "~> 6.0"},
    {:hammer_plug, "~> 3.0"}
  ]
end
Open Source Agenda is not affiliated with "Hammer Plug" Project. README Source: ExHammer/hammer-plug
Stars
61
Open Issues
10
Last Commit
4 months ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating