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
use Mojolicious::Lite; | |
get '/a' => sub { | |
my $self = shift; | |
$self->res->code(403); | |
}; | |
app->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
python -m SimpleHTTPServer |
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
$self->render('ok!') | |
if $self->ssl_auth( sub { | |
return 1 if shift->peer_certificate('commonName') eq 'whatever' | |
} ); |
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
$self->render('ok!') | |
if $self->params_auth( userinput => passinput => captchainput => | |
sub { return 1 if "@_" eq 'username password 58ehda3' } | |
); |
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
$self->render('ok!') | |
if $self->basic_auth( | |
realm => sub { return 1 if "@_" eq 'username password' } | |
); |
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
Mojo::UserAgent->new->get('http://www.google.com/search?q=mojolicious') | |
->res->dom->find('h3.r a') | |
->each( sub { print shift->all_text . "\n" } ); |
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
my $dom = Mojo::DOM->new; | |
$dom->parse(' | |
<div> | |
<h1 id="hope">A new hope</h1> | |
<p>A neat article about Mojolicious</p> | |
</div> | |
'); | |
print $dom->at('#hope')->text; |
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
curl -L cpanmin.us | perl - Mojolicious |
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
my $t = Test::Mojo->new( app => 'MyApp' ); | |
$t->get_ok('/welcome')->status_is(200); |
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
$t->max_redirects(3) | |
->get_ok('/welcome') | |
->status_is(200) | |
->content_like(qr/some text/) | |
->content_type_is('text/html'); |
OlderNewer