|
|
|
@ -20,6 +20,9 @@ Flight::set('flight.v2.output_buffering', true);
|
|
|
|
|
// Test 1: Root route
|
|
|
|
|
Flight::route('/', function () {
|
|
|
|
|
echo '<span id="infotext">Route text:</span> Root route works!';
|
|
|
|
|
if (Flight::request()->query->redirected) {
|
|
|
|
|
echo '<br>Redirected from /redirect route successfully!';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Flight::route('/querytestpath', function () {
|
|
|
|
|
echo '<span id="infotext">Route text:</span> This ir query route<br>';
|
|
|
|
@ -93,9 +96,32 @@ Flight::route('/protected', function () {
|
|
|
|
|
Flight::route('/template/@name', function ($name) {
|
|
|
|
|
Flight::render('template.phtml', ['name' => $name]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Test 8: Throw an error
|
|
|
|
|
Flight::route('/error', function () {
|
|
|
|
|
trigger_error('This is a successful error');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Test 9: JSON output (should not output any other html)
|
|
|
|
|
Flight::route('/json', function () {
|
|
|
|
|
echo "\n\n\n\n\n";
|
|
|
|
|
Flight::json(['message' => 'JSON renders successfully!']);
|
|
|
|
|
echo "\n\n\n\n\n";
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Test 10: Halt
|
|
|
|
|
Flight::route('/halt', function () {
|
|
|
|
|
Flight::halt(400, 'Halt worked successfully');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Test 11: Redirect
|
|
|
|
|
Flight::route('/redirect', function () {
|
|
|
|
|
Flight::redirect('/?redirected=1');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Flight::set('flight.views.path', './');
|
|
|
|
|
Flight::map('error', function (Throwable $error) {
|
|
|
|
|
echo "<h1> An error occurred, mapped error method worked, error bellow </h1>";
|
|
|
|
|
echo "<h1> An error occurred, mapped error method worked, error below </h1>";
|
|
|
|
|
echo '<pre style="border: 2px solid red; padding: 21px; background: lightgray; font-weight: bold;">';
|
|
|
|
|
echo str_replace(getenv('PWD'), "***CLASSIFIED*****", $error->getTraceAsString());
|
|
|
|
|
echo "</pre>";
|
|
|
|
@ -164,6 +190,10 @@ echo '
|
|
|
|
|
<li><a href="/querytestpath?test=1&variable2=uuid&variable3=tester">Query path</a></li>
|
|
|
|
|
<li><a href="/postpage">Post method test page - should be 404</a></li>
|
|
|
|
|
<li><a href="' . Flight::getUrl('final_group') . '">Mega group</a></li>
|
|
|
|
|
<li><a href="/error">Error</a></li>
|
|
|
|
|
<li><a href="/json">JSON</a></li>
|
|
|
|
|
<li><a href="/halt">Halt</a></li>
|
|
|
|
|
<li><a href="/redirect">Redirect</a></li>
|
|
|
|
|
</ul>';
|
|
|
|
|
Flight::before('start', function ($params) {
|
|
|
|
|
echo '<div id="container">';
|
|
|
|
|