Skip to content

Instantly share code, notes, and snippets.

@brianmed
Created July 8, 2013 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianmed/5946528 to your computer and use it in GitHub Desktop.
Save brianmed/5946528 to your computer and use it in GitHub Desktop.
Attemp at catch all route
#!/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