header("Content-Type: application/json");
    echo json_encode($tweetDAO->selectAll(), JSON_NUMERIC_CHECK);
    exit;
});
$app->get('/tweets/:id/?', function ($id) use($tweetDAO) {
    header("Content-Type: application/json");
    echo json_encode($tweetDAO->selectById($id), JSON_NUMERIC_CHECK);
    exit;
});
$app->post('/tweets/?', function () use($app, $tweetDAO) {
    header("Content-Type: application/json");
    $post = $app->request->post();
    if (empty($post)) {
        $post = (array) json_decode($app->request()->getBody());
    }
    echo json_encode($tweetDAO->insert($post), JSON_NUMERIC_CHECK);
    exit;
});
$app->delete('/tweets/:id/?', function ($id) use($tweetDAO) {
    header("Content-Type: application/json");
    echo json_encode($tweetDAO->delete($id));
    exit;
});
$app->put('/tweets/:id/?', function ($id) use($app, $tweetDAO) {
    header("Content-Type: application/json");
    $post = $app->request->post();
    if (empty($post)) {
        $post = (array) json_decode($app->request()->getBody());
    }
    echo json_encode($tweetDAO->update($id, $post), JSON_NUMERIC_CHECK);
    exit;