Determine if the rate limit has been exceeded.
public exceededRateLimit ( ) : boolean | ||
return | boolean |
/** * Perform rate limiting before a request is executed. * * @param \Dingo\Api\Http\Request $request * @param \Closure $next * * @throws \Symfony\Component\HttpKernel\Exception\HttpException * * @return mixed */ public function handle($request, Closure $next) { $route = $this->router->getCurrentRoute(); if ($route->hasThrottle()) { $this->handler->setThrottle($route->getThrottle()); } $this->handler->rateLimitRequest($request, $route->getRateLimit(), $route->getRateExpiration()); if ($this->handler->exceededRateLimit()) { throw new HttpException(403, 'You have exceeded your rate limit.', null, $this->getHeaders()); } $response = $next($request); if ($this->handler->requestWasRateLimited()) { return $this->responseWithHeaders($response); } return $response; }