Пример #1
0
 function testRoutedResult404()
 {
     // NOTE: test config where the app is served from a subdirectory of the webserver, like http://localhost/app1
     $router = new \Core3\Web\RequestRouter();
     $router->setApplicationDirectoryRoot(__DIR__);
     $router->setApplicationWebRoot('/');
     $res = $router->route('/wrong/path', 'GET');
     // TODO how can wwe verify http code is 404 ?
     $this->assertEquals("<html>\n" . "\n" . "<title>404 error - file not found!</title>\n" . "\n" . "/wrong/path not found\n" . "\n" . "</html>\n", $res);
 }
Пример #2
0
<?php

/**
 * This is the application router
 */
require_once 'bootstrap.php';
$request = '';
if (isset($_SERVER['REDIRECT_URL'])) {
    $request = $_SERVER['REDIRECT_URL'];
} else {
    if (isset($_SERVER['REQUEST_URI'])) {
        $request = $_SERVER['REQUEST_URI'];
    }
}
if (!isset($_SERVER['REQUEST_METHOD'])) {
    die('error');
}
$requestMethod = $_SERVER['REQUEST_METHOD'];
$router = new \Core3\Web\RequestRouter();
$router->setApplicationDirectoryRoot(__DIR__);
$router->setApplicationWebRoot(dirname($_SERVER['SCRIPT_NAME']));
\Core3\Writer\HttpHeader::sendContentType('text/html; charset=utf-8');
echo $router->route($request, $requestMethod);