File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -143,14 +143,19 @@ the number of requests to the API::
143143In other scenarios you may want instead to wait as long as needed until a new
144144token is available. In those cases, use the ``wait() `` method::
145145
146- // src/Controller/LuckyController.php
147- // ...
146+ // src/Controller/ApiController.php
147+ namespace App\Controller;
148+
149+ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
150+ use Symfony\Component\HttpFoundation\Request;
151+ use Symfony\Component\RateLimiter\Limiter;
148152
149153 class ApiController extends AbstractController
150154 {
151- public function registerUser(LimiterInterface $authenticatedApiLimiter)
155+ public function registerUser(Request $request, Limiter $authenticatedApiLimiter)
152156 {
153- $limiter = $authenticatedApiLimiter->create($request->getClientIp());
157+ $apiKey = $request->headers->get('apikey');
158+ $limiter = $authenticatedApiLimiter->create($apiKey);
154159
155160 // this blocks the application until the given number of tokens can be consumed
156161 do {
You can’t perform that action at this time.
0 commit comments