Created
July 8, 2013 06:03
-
-
Save brianmed/5946528 to your computer and use it in GitHub Desktop.
Attemp at catch all route
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
#!/opt/perl | |
use Mojolicious::Lite; | |
get '/' => sub { | |
my $self = shift; | |
$self->render('index'); | |
}; | |
get '/catcher' => sub { | |
my $self = shift; | |
$self->render(); | |
}; | |
hook after_dispatch => sub { | |
my $c = shift; | |
unless ($c->match->endpoint) { | |
$c->redirect_to("/catcher"); | |
} | |
}; | |
app->start; | |
__DATA__ | |
@@ index.html.ep | |
% layout 'default'; | |
% title 'Welcome'; | |
Welcome to the Mojolicious real-time web framework! | |
@@ layouts/default.html.ep | |
<!DOCTYPE html> | |
<html> | |
<head><title><%= title %></title></head> | |
<body><%= content %></body> | |
</html> | |
@@ catcher.html.ep | |
% layout 'default'; | |
% title 'Catch-All'; | |
Found it! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment