Skip to content

Instantly share code, notes, and snippets.

@aambrozkiewicz
Created August 6, 2011 15:50
Show Gist options
  • Save aambrozkiewicz/1129453 to your computer and use it in GitHub Desktop.
Save aambrozkiewicz/1129453 to your computer and use it in GitHub Desktop.
<?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