Пример #1
0
    } else {
        sendResponse(400, initBody(true, "An error occurred."), null);
    }
});
$app->post('/events', 'checkToken', function () use($app) {
    $values = array();
    $values['userId'] = $app->request->post("user_id");
    $values['title'] = $app->request->post("title");
    $values['desc'] = $app->request->post("desc");
    $values['date'] = $app->request->post("date");
    $values['category'] = $app->request->post("category");
    $values['participants'] = $app->request->post("participants");
    $values['registration'] = $app->request->post("registration");
    $values['address'] = $app->request->post("address");
    $db = new dbHandler();
    if ($db->createEvent($values)) {
        sendResponse(201, initBody(false, null), null);
    } else {
        sendResponse(400, initBody(true, "An error occurred."), null);
    }
});
$app->delete('/events/:id', 'checkToken', function ($id) use($app) {
    $db = new dbHandler();
    if ($db->deleteEvent($id)) {
        sendResponse(204, initBody(false, null), null);
    } else {
        sendResponse(400, initBody(true, "An error occurred."), null);
    }
});
$app->get('/events', function () use($app) {
    $db = new dbHandler();