Created
August 6, 2011 15:50
-
-
Save aambrozkiewicz/1129453 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// error_reporting(E_ALL); | |
require_once 'app/autoload.php'; | |
require_once 'app/view.php'; | |
$app = new App\App; | |
$app->get('/', function() { | |
echo view::render('views/index.php'); | |
})->get('/404', function() { | |
echo '404'; | |
})->get('/(\w+)', function($name) use ($app) { | |
echo 'Hello ' . $app->escape($name); | |
})->error(function(Exception $e) { | |
if ($e instanceof LoginRequiredException) | |
die('Login required'); | |
})->error(function(Exception $e, $code) use ($app) { | |
$code == 404 ? $app->redirect('/404') : true; | |
})->before(function() { | |
// TODO: counter, LoginRequiredException if not. | |
})->run(); | |
class LoginRequiredException extends Exception {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment