Skip to content

Instantly share code, notes, and snippets.

@memowe
Created January 15, 2012 10: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 memowe/1615383 to your computer and use it in GitHub Desktop.
Save memowe/1615383 to your computer and use it in GitHub Desktop.
mojolicious example
This is b. answer: <%= $answer %>
package Inokenty::Foo::Bar::Baz;
use Mojo::Base 'Mojolicious::Controller';
sub acshun {
shift->stash(answer => 42);
}
1;
__END__
#!/usr/bin/env perl
use Mojo::Base -strict;
use File::Basename 'dirname';
use File::Spec;
use lib join '/', File::Spec->splitdir(dirname(__FILE__)), 'lib';
use lib join '/', File::Spec->splitdir(dirname(__FILE__)), '..', 'lib';
# Check if Mojolicious is installed;
die <<EOF unless eval 'use Mojolicious::Commands; 1';
It looks like you don't have the Mojolicious framework installed.
Please visit http://mojolicio.us for detailed installation instructions.
EOF
# Application
$ENV{MOJO_APP} ||= 'Inokenty';
# Start commands
Mojolicious::Commands->start;
package Inokenty;
use Mojo::Base 'Mojolicious';
sub startup {
my $self = shift;
my $r = $self->routes;
$r->get('/a' => sub { shift->render(template => 'a') });
$r->route('/b')->to('foo-bar-baz#acshun');
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment