Skip to content

Commit

Permalink
Add usage example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
errm committed Jun 3, 2024
1 parent f6202ac commit a07c650
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Millrace

## Usage

```
class UsersController
before_action Millrace::RateLimit.new(
name: "follows",
rate: 1/60.0, # 1 request per minute
window: 1.minute,
penalty: 10.minutes,
), only: :create
rescue_from Millrace::RateLimited do |error|
# perhaps record metrics here
response.set_header "Retry-After", error.retry_after
head :too_many_requests
end
...
end
```

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/millrace. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/millrace/blob/main/CODE_OF_CONDUCT.md).
Expand Down

0 comments on commit a07c650

Please sign in to comment.