Created
January 15, 2012 10:37
-
-
Save memowe/1615383 to your computer and use it in GitHub Desktop.
mojolicious example
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
This is a. |
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
This is b. answer: <%= $answer %> |
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
package Inokenty::Foo::Bar::Baz; | |
use Mojo::Base 'Mojolicious::Controller'; | |
sub acshun { | |
shift->stash(answer => 42); | |
} | |
1; | |
__END__ |
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
#!/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; |
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
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