$res = $db->deletexml($id); echoResponse(200, $res); }); $app->post('/newcomment', function () use($app) { $json = $app->request->getBody(); $input = json_decode($json, true); $id = $input['id']; $author = $input['author']; $comment = $input['comment']; $db = new DbHandler(); $res = $db->addcomment($id, $author, $comment); echo $res; }); $app->get('/comment/:id', function ($id) use($app) { $db = new DBHandler(); $res = $db->getcomment($id); echoResponse(200, $res); }); /** * Echoing json response to client * * @param String $status_code * Http response code * @param Int $response * Json response */ function echoResponse($status_code, $response) { $app = \Slim\Slim::getInstance(); // Http response code $app->status($status_code);