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 '/' => {text => 'Hello Mojo!'}; | |
| 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
| $ mkdir hellomojo | |
| $ cd hellomojo | |
| $ touch myapp.pl | |
| $ chmod +x myapp.pl | |
| $ touch Makefile.PL | |
| $ touch Perloku | |
| $ chmod +x Perloku |
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
| $ heroku login | |
| ... |
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
| package Test; | |
| use Mojo::Base -base; | |
| sub foo : lvalue { shift->{foo} } | |
| package main; | |
| use Mojo::Base -strict; | |
| my $test = Test->new; | |
| $test->foo = 'works!'; |
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
| use Mojolicious::Lite; | |
| use EV; | |
| use AnyEvent; | |
| use AnyEvent::Util; | |
| get '/' => sub { | |
| my $self = shift; | |
| # Run Perl oneliner in separate process and capture STDOUT | |
| fork_call { |
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
| use Mojolicious::Lite; | |
| use EV; | |
| use IO::Async::Process; | |
| use IO::Async::Loop::EV; | |
| my $loop = IO::Async::Loop::EV->new; | |
| get '/' => sub { | |
| my $self = shift; |
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
| package MyApp::Controller::Bar; | |
| use Mojolicious::Lite; | |
| get '/test' => sub { | |
| my $self = shift; | |
| $self->render('test'); | |
| }; | |
| 1; | |
| __DATA__ |
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
| package Mojolicious::Command::files; | |
| use Mojo::Base 'Mojo::Command'; | |
| use Mojo::Home; | |
| has description => "List templates and static files.\n"; | |
| has usage => "usage: $0 files\n"; | |
| sub run { | |
| my $self = shift; |
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
| # StreamingPSGI - Everything is streaming, no special cases | |
| my $env = { | |
| SERVER_NAME => 'localhost', | |
| SERVER_PORT => 80, | |
| SCRIPT_NAME => '', | |
| REQUEST_METHOD => 'GET', | |
| HTTP_CONTENT_LENGTH => 12, | |
| version => 3, | |
| url_scheme => 'http', | |
| read => sub {...}, |
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; | |
| use Coro; | |
| use Mojo::IOLoop; | |
| Mojo::IOLoop->recurring(0 => sub {cede}); | |
| hook around_dispatch => sub { | |
| my $next = shift; | |
| async { $next->() }; |