https://github.com/exhammer/hammer-plug
A plug to apply rate-limiting with Hammer
https://github.com/exhammer/hammer-plug
elixir elixir-lang elixir-library phoenix plug rate-limiting throttling
Last synced: 5 months ago
JSON representation
A plug to apply rate-limiting with Hammer
- Host: GitHub
- URL: https://github.com/exhammer/hammer-plug
- Owner: ExHammer
- License: mit
- Created: 2018-06-16T19:47:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-05-12T07:45:29.000Z (5 months ago)
- Last Synced: 2025-05-15T08:23:18.184Z (5 months ago)
- Topics: elixir, elixir-lang, elixir-library, phoenix, plug, rate-limiting, throttling
- Language: Elixir
- Homepage: https://hexdocs.pm/ExHammer/hammer-plug
- Size: 67.4 KB
- Stars: 70
- Watchers: 2
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Hammer.Plug
> [!WARNING - End-of-Life - 2024-12-20]
> This library is End-of-Life. With the 7.x release, it s much easier to create your own
> rate limiters. But shipping a common plug do not make sense anymore. Please consider
> using custom function plugs. See the [Hammer documentation](https://hexdocs.pm/hammer/7.0.0-rc.3/tutorial.html#using-hammer-as-a-plug-in-phoenix) for more information.
>---
[](https://github.com/ExHammer/hammer-plug/actions/workflows/ci.yml) [](https://hex.pm/packages/hammer_plug) [](https://hexdocs.pm/hammer_plug)
[](https://hex.pm/packages/hammer_plug)
[](https://github.com/ExHammer/hammer-plug/blob/master/LICENSE.md)[Hammer](https://github.com/ExHammer/hammer) is a rate-limiter for Elixir, with pluggable storage backends.
This library is a [plug](https://hexdocs.pm/plug/readme.html) helper, to easily add rate-limiting to Phoenix applications,
or any Elixir system that uses plug.Example:
```elixir
# Allow ten uploads per 60 seconds
plug Hammer.Plug, [
rate_limit: {"video:upload", 60_000, 10},
by: {:session, :user_id}
] when action == :upload_video_filedef upload_video_file(conn, _opts) do
# ...
end
```## Documentation
See the [Hammer documentation page](https://hexdocs.pm/hammer) for more info on Hammer itself.
See the [Hammer.Plug docs](https://hexdocs.pm/hammer_plug) for more info about this library and how to use it, specifically the [Hammer.Plug](https://hexdocs.pm/hammer_plug/Hammer.Plug.html#content) module.
## Installation
Hammer-Plug is avaliable [available in Hex](https://hex.pm/docs/publish), the package can be installed by adding `hammer_plug` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:hammer, "~> 6.0"},
{:hammer_plug, "~> 3.0"}
]
end
```