use new rate limiting

This commit is contained in:
Taylor Otwell 2020-08-27 13:36:32 -05:00
parent 23205e270f
commit ced3e50bca
2 changed files with 18 additions and 1 deletions

View File

@ -40,7 +40,7 @@ class Kernel extends HttpKernel
],
'api' => [
'throttle:60,1',
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];

View File

@ -2,7 +2,10 @@
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
@ -23,6 +26,8 @@ class RouteServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::middleware('web')
->group(base_path('routes/web.php'));
@ -32,4 +37,16 @@ public function boot()
->group(base_path('routes/api.php'));
});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60);
});
}
}