Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[RateLimiter] Use RateLimiterFactory with custom limit #51401

Copy link
Copy link
@IlonavD

Description

@IlonavD
Issue body actions

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

No one assigned

    Labels

    DXDX = Developer eXperience (anything that improves the experience of using Symfony)DX = Developer eXperience (anything that improves the experience of using Symfony)RateLimiter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.