Skip to content

Instantly share code, notes, and snippets.

@thannaske
Created January 3, 2020 08:39
Show Gist options
  • Save thannaske/2422ede6d64d77f0ea70827b1b63e202 to your computer and use it in GitHub Desktop.
Save thannaske/2422ede6d64d77f0ea70827b1b63e202 to your computer and use it in GitHub Desktop.
<?php
// Allow up to 60 requests in 1 minute for that route (= 1 req/s)
Route::get('api/v1/user', 'Api\UserController@index')->middleware('throttle:60,1');
// Allow up to 60 requests in 60 minutes for that route (= 1 req/m)
Route::post('api/v1/user', 'Api\UserController@store')->middleware('throttle:60,60');
// Rate Limiting for a whole group of routes
Route::group(['middleware' => 'throttle:60,1'], function () {
// [...]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment