<?php
namespace EEPROM;

require_once __DIR__ . '/../eeprom.php';

set_exception_handler(function(\Throwable $ex) {
    \Sentry\captureException($ex);

    ob_clean();
    http_response_code(500);

    if(PRM_DEBUG) {
        header('Content-Type: text/plain; charset=utf-8');
        echo (string)$ex;
    } else echo '500';
    exit;
});

ob_start();

$request = \Index\Http\HttpRequest::fromRequest();
$isApiDomain = $request->getHeaderLine('Host') === $cfg->getString('domain:api');

$eeprom->createRouting($isApiDomain)->dispatch($request);