Skip to content

Instantly share code, notes, and snippets.

@sharifulin
Created May 24, 2010 15:37
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 sharifulin/412016 to your computer and use it in GitHub Desktop.
Save sharifulin/412016 to your computer and use it in GitHub Desktop.
Mojolicious routes: bridge
#!/usr/bin/perl
use common::sense;
use lib qw(../lib lib);
$ENV{MOJO_APP} ||= 'App';
use Mojolicious::Commands; Mojolicious::Commands->start;
package App;
use common::sense;
use base 'Mojolicious';
sub startup {
my $self = shift;
my $r = $self->routes;
my $auth = $r->bridge->to('auth#check');
$auth->route('/about/')->to('pref#about');
$auth->route('/gift/')->to('gift#index');
my $album = $auth->bridge->to('album#allow');
$album->route('/album/create/')->to('album#create');
}
package App::Auth;
use base 'Mojolicious::Controller';
sub check { 1 }
package App::Album;
use base 'Mojolicious::Controller';
sub allow { 1 }
sub create { shift->render_text(__PACKAGE__) }
package App::Gift;
use base 'Mojolicious::Controller';
sub index { shift->render_text(__PACKAGE__) }
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment