"done": false }, { "id": 2, "description": "Learn JavaScript", "done": false }, { "id": 3, "description": "Learn English", "done": false } ] */ $app->get('/tasks1', function () use($app) { $tasks = TaskService::listTasks(); //Define what kind is this response $app->response()->header('Content-Type', 'application/json'); echo json_encode($tasks); }); /* HTTP GET http://domain/api/tasks/1 RESPONSE 200 OK { "id": 1, "description": "Learn REST", "done": false } RESPONSE 204 NO CONTENT */ $app->get('/tasks/:id', function ($id) use($app) {
RESPONSE 200 OK [ { "id": "1", "name": "Lidy Segura", "email": "*****@*****.**" }, { "id": "2", "name": "Edy Segura", "email": "*****@*****.**" } ] */ $app->get('/guests/', function () use($app) { $guests = TaskService::listTasks(); $app->response()->header('Content-Type', 'application/json'); echo json_encode($guests); }); /* HTTP POST /api/guests REQUEST Body { "name": "Lidy Segura", "email": "*****@*****.**" } RESPONSE 200 OK { "name": "Thiis is a test", "email": "*****@*****.**",