接口请求限流

This commit is contained in:
Wisp X
2022-02-20 14:27:23 +08:00
parent 4342c47189
commit b6429aa7cf
2 changed files with 37 additions and 0 deletions
+5
View File
@@ -5,6 +5,7 @@ namespace App\Exceptions;
use App\Http\Api;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\Exceptions\ThrottleRequestsException;
use Throwable;
class Handler extends ExceptionHandler
@@ -41,6 +42,10 @@ class Handler extends ExceptionHandler
$this->reportable(function (Throwable $e) {
//
});
$this->renderable(function (ThrottleRequestsException $e) {
return $this->error($e->getMessage())->setStatusCode(429);
});
}
protected function unauthenticated($request, AuthenticationException $exception)