Created
August 19, 2014 09:14
-
-
Save anonymous/0245bd4bfed5963c7261 to your computer and use it in GitHub Desktop.
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 Narf::Controller::Example; | |
use Mojo::Base 'Mojolicious::Controller'; | |
use Data::Dumper; | |
sub welcome { | |
my $self = shift; | |
$self->session(foo => 123); | |
print Dumper $self->session; | |
print Dumper $self->app->session; | |
$self->render(msg => 'Welcome to the Mojolicious real-time web framework!'); | |
} | |
1; |
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
% perl script/narf get / | |
[Tue Aug 19 11:14:31 2014] [debug] Your secret passphrase needs to be changed!!! | |
[Tue Aug 19 11:14:31 2014] [debug] GET "/". | |
[Tue Aug 19 11:14:31 2014] [debug] Routing to controller "Narf::Controller::Example" and action "welcome". | |
$VAR1 = { | |
'foo' => 123 | |
}; | |
$VAR1 = {}; | |
[Tue Aug 19 11:14:31 2014] [debug] Rendering template "example/welcome.html.ep". | |
[Tue Aug 19 11:14:31 2014] [debug] Rendering template "layouts/default.html.ep". | |
[Tue Aug 19 11:14:31 2014] [debug] 200 OK (0.024639s, 40.586/s). | |
<!DOCTYPE html> | |
<html> | |
<head><title>Welcome</title></head> | |
<body><h2>Welcome to the Mojolicious real-time web framework!</h2> | |
This page was generated from the template "templates/example/welcome.html.ep" | |
and the layout "templates/layouts/default.html.ep", | |
<a href="/">click here</a> to reload the page or | |
<a href="/index.html">here</a> to move forward to a static page. | |
</body> | |
</html> |
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 Narf; | |
use Mojo::Base 'Mojolicious'; | |
# This method will run once at server start | |
sub startup { | |
my $self = shift; | |
# Documentation browser under "/perldoc" | |
$self->plugin('PODRenderer'); | |
# Router | |
my $r = $self->routes; | |
# Normal route to controller | |
$r->get('/')->to('example#welcome'); | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment