@@ -167,14 +167,15 @@ the number of requests to the API::
167
167
namespace App\Controller;
168
168
169
169
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
170
+ use Symfony\Component\HttpFoundation\Request;
170
171
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
171
172
use Symfony\Component\RateLimiter\RateLimiterFactory;
172
173
173
174
class ApiController extends AbstractController
174
175
{
175
176
// if you're using service autowiring, the variable name must be:
176
177
// "rate limiter name" (in camelCase) + "Limiter" suffix
177
- public function index(RateLimiterFactory $anonymousApiLimiter)
178
+ public function index(Request $request, RateLimiterFactory $anonymousApiLimiter)
178
179
{
179
180
// create a limiter based on a unique identifier of the client
180
181
// (e.g. the client's IP address, a username/email, an API key, etc.)
@@ -272,12 +273,13 @@ the :class:`Symfony\\Component\\RateLimiter\\Reservation` object returned by the
272
273
namespace App\Controller;
273
274
274
275
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
276
+ use Symfony\Component\HttpFoundation\Request;
275
277
use Symfony\Component\HttpFoundation\Response;
276
278
use Symfony\Component\RateLimiter\RateLimiterFactory;
277
279
278
280
class ApiController extends AbstractController
279
281
{
280
- public function index(RateLimiterFactory $anonymousApiLimiter)
282
+ public function index(Request $request, RateLimiterFactory $anonymousApiLimiter)
281
283
{
282
284
$limiter = $anonymousApiLimiter->create($request->getClientIp());
283
285
$limit = $limiter->consume();
0 commit comments