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::
143
143
In other scenarios you may want instead to wait as long as needed until a new
144
144
token is available. In those cases, use the ``wait() `` method::
145
145
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;
148
152
149
153
class ApiController extends AbstractController
150
154
{
151
- public function registerUser(LimiterInterface $authenticatedApiLimiter)
155
+ public function registerUser(Request $request, Limiter $authenticatedApiLimiter)
152
156
{
153
- $limiter = $authenticatedApiLimiter->create($request->getClientIp());
157
+ $apiKey = $request->headers->get('apikey');
158
+ $limiter = $authenticatedApiLimiter->create($apiKey);
154
159
155
160
// this blocks the application until the given number of tokens can be consumed
156
161
do {
You can’t perform that action at this time.
0 commit comments