mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-02 12:20:17 +08:00
This commit adds the `add_request_rate_limiter` plugin API which allows plugins to add custom rate limiters on top of the default rate limiters which requests by a user's id or the request's IP address.
Example to add a rate limiter that rate limits all requests from Googlebot under the same rate limit bucket:
```
add_request_rate_limiter(
identifier: :country,
key: ->(request) { "country/#{DiscourseIpInfo.get(request.ip)[:country]}" },
activate_when: ->(request) { DiscourseIpInfo.get(request.ip)[:country].present? },
)
```
|
||
|---|---|---|
| .. | ||
| anonymous_cache.rb | ||
| csp_script_nonce_injector.rb | ||
| discourse_public_exceptions.rb | ||
| enforce_hostname.rb | ||
| missing_avatars.rb | ||
| omniauth_bypass_middleware.rb | ||
| processing_request.rb | ||
| request_tracker.rb | ||
| turbo_dev.rb | ||