Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Laravel API Rate Limiting and Dynamic Rate Limiting: https://www.cloudways.com/blog/laravel-and-api-rate-limiting/
Route::group(['prefix' => 'api/v1'], function () {
Route::get('/getTasks', function () {
return Task::all();
});
Route::post('/addTask', function (Request $request) {
$validator = Validator::make($request->all(), [
'names' => 'required|max:255',
]);
if ($validator->fails()) {
return response()->json(['error' => $validator->messages()],
200);
}
$task = new Task;
$task->names = $request->names;
$task->save();
return response()->json(['response' => "Added {$request->names} to tasks."],
200);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.