<?php
require __DIR__ . '/vendor/autoload.php';

use App\Controller\ContentController;
use DI\Container;
use Slim\Factory\AppFactory;

$container = new Container();
$container->set('pdo', function() {
    $pdo = new PDO('sqlite:' . __DIR__ . '/data.sqlite3');
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    return $pdo;
});

AppFactory::setContainer($container);
$app = AppFactory::create();

$contentController = new ContentController();
$app->get('/content/{key}', [$contentController, 'getContent']);

$app->run();
