@@ -167,14 +167,15 @@ the number of requests to the API::
167167 namespace App\Controller;
168168
169169 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
170+ use Symfony\Component\HttpFoundation\Request;
170171 use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
171172 use Symfony\Component\RateLimiter\RateLimiterFactory;
172173
173174 class ApiController extends AbstractController
174175 {
175176 // if you're using service autowiring, the variable name must be:
176177 // "rate limiter name" (in camelCase) + "Limiter" suffix
177- public function index(RateLimiterFactory $anonymousApiLimiter)
178+ public function index(Request $request, RateLimiterFactory $anonymousApiLimiter)
178179 {
179180 // create a limiter based on a unique identifier of the client
180181 // (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
272273 namespace App\Controller;
273274
274275 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
276+ use Symfony\Component\HttpFoundation\Request;
275277 use Symfony\Component\HttpFoundation\Response;
276278 use Symfony\Component\RateLimiter\RateLimiterFactory;
277279
278280 class ApiController extends AbstractController
279281 {
280- public function index(RateLimiterFactory $anonymousApiLimiter)
282+ public function index(Request $request, RateLimiterFactory $anonymousApiLimiter)
281283 {
282284 $limiter = $anonymousApiLimiter->create($request->getClientIp());
283285 $limit = $limiter->consume();
0 commit comments