mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: add Retry-After header if needed
This commit is contained in:
@@ -64,12 +64,13 @@ class DomainRefreshController extends AbstractController
|
||||
|
||||
if (false === $kernel->isDebug() && true === $this->getParameter('limited_features')) {
|
||||
$limiter = $this->rdapRequestsLimiter->create($userId);
|
||||
$limit = $limiter->consume();
|
||||
|
||||
if (false === $limiter->consume()->isAccepted()) {
|
||||
if (false === $limit->isAccepted()) {
|
||||
$this->logger->warning('User {username} was rate limited by the API.', [
|
||||
'username' => $this->getUser()->getUserIdentifier(),
|
||||
]);
|
||||
throw new TooManyRequestsHttpException();
|
||||
throw new TooManyRequestsHttpException($limit->getRetryAfter()->getTimestamp() - time());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user