-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Labels
DXDX = Developer eXperience (anything that improves the experience of using Symfony)DX = Developer eXperience (anything that improves the experience of using Symfony)RateLimiter
Description
Description
Currently the RateLimitFactory fetches the configuration and determines the limit based of that. We'd like to be more flexible with that, allowing certain users a higher limit than others. Adding an optional parameter to the create
function which will default to the limit set in the config.
Example
// src/Controller/ApiController.php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\RateLimiter\RateLimiterFactory;
class ApiController extends AbstractController
{
public function registerUser(Request $request, RateLimiterFactory $authenticatedApiLimiter): Response
{
$user = $request->getUser();
$limiter = $authenticatedApiLimiter->create($user->getApiKey(), $user->getRateLimit());
// ...
}
// ...
}
I am happy to make this PR
Metadata
Metadata
Assignees
Labels
DXDX = Developer eXperience (anything that improves the experience of using Symfony)DX = Developer eXperience (anything that improves the experience of using Symfony)RateLimiter