Php Laravel API将1个ip地址排除在速率限制之外

Php Laravel API将1个ip地址排除在速率限制之外,php,laravel,middleware,throttling,Php,Laravel,Middleware,Throttling,在LaravelAPI上,我使用默认的中间件设置了速率限制以进行节流 Route::group(['prefix' => 'products'], function() { Route::get('/', ['as' => 'products.index', 'uses' => 'CustomerProductController@index'])->middleware('throttle:60,1'); Route::get('/{product}',

在LaravelAPI上,我使用默认的中间件设置了速率限制以进行节流

Route::group(['prefix' => 'products'], function() {
    Route::get('/', ['as' => 'products.index', 'uses' => 'CustomerProductController@index'])->middleware('throttle:60,1');
    Route::get('/{product}', ['as' => 'products.show', 'uses' => 'CustomerProductController@show'])->middleware('throttle:50,1');
});
现在,我需要制作自己的中间件,从节流中排除1个ip地址。 但不知何故,我只能找到一些建议,比如限制一组ip地址


有人能给我一个正确的方向吗?

这里是我将要做的简短概述

步骤1

创建一个新的中间件,即
ThrottleRequestsWithIp

php artisan make:middleware ThrottleRequestsWithIp
步骤2

让它扩展原来的throttle中间件类
\illumb\Routing\middleware\ThrottleRequests

如果您想查看原始的框架中间件,可以在
/vendor/laravel/framework/src/illumb/Routing/middleware/ThrottleRequests.php

覆盖
handle
方法以检查IP地址,如果找不到,则调用父方法

这就是你的
App\Http\Middleware\ThrottleRequestsWithIp
的样子


它确实有帮助。谢谢。
'throttleIp' => \App\Http\Middleware\ThrottleRequestsWithIp::class