$app->put('/tasks/', function () use($app) { $taskJson = $app->request()->getBody(); $updatedTask = json_decode($taskJson, true); if ($updatedTask && $updatedTask['id']) { if (TaskService::update($updatedTask)) { echo "Task {$updatedTask['description']} updated"; } else { $app->response->setStatus('404'); echo "Task not found"; } } else { $app->response->setStatus(400); echo "Malformat JSON"; } }); /* HTTP DELETE http://domain/api/tasks/1 RESPONSE 200 OK Task with id = 1 was deleted RESPONSE 404 Task with id = 1 not found */ $app->delete('/tasks/:id', function ($id) use($app) { if (TaskService::delete($id)) { echo "Task with id = {$id} was deleted"; } else { $app->response->setStatus('404'); echo "Task with id = {$id} not found"; } }); $app->run();