sendResponse(200, initBody(false, null), $friends); } else { sendResponse(400, initBody(true, "An error occurred."), null); } }); $app->post('/users/:userId/friends/:friendId', 'checkToken', function ($userId, $friendId) use($app) { $db = new dbHandler(); if ($db->addFriend($userId, $friendId)) { sendResponse(200, initBody(false, null), null); } else { sendResponse(400, initBody(true, "An error occurred."), null); } }); $app->delete('/users/:userId/friends/:friendId', 'checkToken', function ($userId, $friendId) use($app) { $db = new dbHandler(); if ($db->deleteFriend($userId, $friendId)) { sendResponse(204, initBody(false, null), null); } else { sendResponse(400, initBody(true, "An error occurred."), null); } }); $app->post('/feedback', 'checkToken', function () use($app) { $db = new dbHandler(); $token = $app->request->headers->get('token'); $message = $app->request->post('message'); if ($db->sendFeedback($token, $message)) { sendResponse(201, initBody(false, null), null); } else { sendResponse(400, initBody(true, "An error occurred."), null); } });