✨ 接口请求限流
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user