Skip to content

Instantly share code, notes, and snippets.

@kraih
Created October 5, 2011 14:23
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 kraih/1264549 to your computer and use it in GitHub Desktop.
Save kraih/1264549 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use Mojolicious::Lite;
# Global logic shared by all routes
under sub {
my $self = shift;
return 1 if $self->req->headers->header('X-Bender');
$self->render(text => "You're not Bender!");
return;
};
# Admin section
group {
# Local logic shared only by routes in this group
under '/admin' => sub {
my $self = shift;
return 1 if $self->req->headers->header('X-Awesome');
$self->render(text => "You're not awesome enough!");
return;
};
# GET /admin/dashboard
get '/dashboard' => {text => 'Nothing to see here yet!'};
};
# GET /welcome
get '/welcome' => {text => 'Hi Bender!'};
app->start;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment