September 2017
Intermediate to advanced
244 pages
6h 44m
English
Rate limiting is also known as throttling. It means that there should be a limit on how much time a particular client is able to hit the API endpoint in a specific time interval. To enable it, we must enable the api.throttling middleware. You can apply throttling on all routes or on specific routes. You will just apply middleware on that particular route as shown here. In our case, we want to enable it for all endpoints, so let's put it in a version group:
$api->version('v1', ['middleware' => 'api.throttle','prefix' => 'api/v1'], function ($api) { $api->resource('posts', "App\Http\Controllers\V1\PostController"); $api->resource('comments', "App\Http\Controllers\V1\CommentController", [ 'except' => ['store', 'index'] ]);$api ...
Read now
Unlock full access