index.php 880 Bytes
Newer Older
1
<?php
raphael.peim's avatar
raphael.peim committed
2 3 4 5 6
    header("Access-Control-Allow-Origin: http://localhost:8080");
    header("Content-Type: application/json; charset=UTF-8");
    header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
    header("Access-Control-Allow-Headers: Content-Type, Authorization");

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
    $rootDirectoryPath = realpath(dirname(__FILE__));
    define ('__ROOT_DIR', $rootDirectoryPath );

    require_once(__ROOT_DIR . "/config/config.php");
    require_once(__ROOT_DIR . '/classes/AutoLoader.class.php');

    $request = Request::getCurrentRequest();
    Response::interceptEchos();

    try {
        $controller = Dispatcher::dispatch($request);
        $response = $controller->execute();
    } catch (Exception $e) {
        $log = Response::getEchos();
        $log .= " " . $e->getMessage();
        $response = Response::errorResponse($log);
    }

    $response->send();
?>