We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The global path limit applying limit to all users. Is there anyway to overwrite limit for specific users?
The text was updated successfully, but these errors were encountered:
@jaytaph Able to achieve it
services.yml
apibundle.listener.rate_limit_checked.set: class: ApiBundle\EventListener\ClientRateLimitListener arguments: [ '@request_stack' ] tags: - { name: kernel.event_listener, event: 'ratelimit.checked.ratelimit', method: 'setRateLimit' }
ClientRateLimitListener.php
<?php namespace ApiBundle\EventListener; use Noxlogic\RateLimitBundle\Events\CheckedRateLimitEvent; use Symfony\Component\HttpFoundation\RequestStack; use Noxlogic\RateLimitBundle\Annotation\RateLimit; class ClientRateLimitListener { /** * @var RequestStack */ private $requestStack; private $container = null; /** * @param RequestStack $requestStack */ public function __construct(RequestStack $requestStack) { $this->requestStack = $requestStack; } public function setRateLimit(CheckedRateLimitEvent $checkedRateLimitEvent) { $request = $this->requestStack->getCurrentRequest(); $customHeader = $request->headers->get('x-custom-header'); if (!empty($customHeader ) && !is_null($customHeader )) { $checkedRateLimitEvent->setRateLimit(new RateLimit(array( 'limit' => 1000, 'period' => 60, 'methods' => array(0 => '*') ))); } } }
Sorry, something went wrong.
No branches or pull requests
The global path limit applying limit to all users. Is there anyway to overwrite limit for specific users?
The text was updated successfully, but these errors were encountered: