This file contains hidden or 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
# Simple "resource" shortcut | |
$r->add_shortcut(resource => sub { | |
my ($r, $name) = @_; | |
# Generate "/$name" route | |
my $resource = $r->route("/$name")->to("$name#"); | |
# Handle POST requests | |
$resource->post->to('#create')->name("create_$name"); |
This file contains hidden or 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
% mojo get http://mojolicio.us 'head > title' | |
<title>Mojolicious Web Framework - Join the Perl revolution!</title> |
This file contains hidden or 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
% mojo get http://mojolicio.us 'a[href]' attr href | |
http://latest.mojolicio.us | |
http://mojolicio.us | |
http://mojolicio.us/perldoc | |
https://github.com/kraih/mojo/wiki | |
https://github.com/kraih/mojo | |
http://search.cpan.org/dist/Mojolicious | |
http://groups.google.com/group/mojolicious | |
http://blog.kraih.com | |
http://twitter.com/kraih |
This file contains hidden or 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
% mojo generate lite_app | |
[exist] /Users/sri | |
[write] /Users/sri/myapp.pl | |
[chmod] myapp.pl 744 | |
% ./myapp.pl routes | |
/perldoc perldoc (?-xism:^/perldoc) | |
/welcome welcome (?-xism:^/welcome) |
This file contains hidden or 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
% mojo generate lite_app | |
[exist] /Users/sri | |
[write] /Users/sri/myapp.pl | |
[chmod] myapp.pl 744 | |
% ./myapp.pl get --verbose --mode testing /welcome 'head > title' text | |
GET /welcome HTTP/1.1 | |
User-Agent: Mojolicious (Perl) | |
Content-Length: 0 | |
Host: localhost:13359 |
This file contains hidden or 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 Mojolicious::Lite; | |
get '/welcome'; | |
app->start; | |
__DATA__ | |
@@ welcome.html.ep |
This file contains hidden or 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
% ./myapp.pl get --mode testing / html all | |
Not Found | |
Page not found, want to go home? | |
% ./myapp.pl get --mode production / html all | |
Dude!Where is my page? |
This file contains hidden or 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 Mojolicious::Lite; | |
get '/welcome' => sub { | |
my $self = shift; | |
$self->render(text => 'Hi there!'); | |
}; | |
app->start; |
This file contains hidden or 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 Mojolicious::Routes; | |
use Mojolicious::Routes::Match; | |
# Create some routes | |
my $r = Mojolicious::Routes->new; | |
$r->get('/:action')->to(controller => 'foo'); | |
# Match method and path against routes |
This file contains hidden or 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
% ./myapp.pl daemon --listen http://[::1]:3000 | |
Thu Mar 10 11:26:59 2011 info Mojo::Server::Daemon:316 [1576]: Server listening (http://[::1]:3000) |