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
# test.pl: | |
#!/usr/bin/env perl | |
use TestApp; | |
TestApp->start; | |
# TestApp.pm: | |
package TestApp; | |
use Mojo::Base '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
#!/usr/bin/env perl | |
use Mojo; | |
use Mojo::Base -strict; | |
my $ua = Mojo::UserAgent->new; | |
$ua->max_redirects(5); | |
my $domain = 'http://api.powerhousemuseum.com'; | |
my $base_url ="$domain/api/v1/category/xml/"; | |
my $api_key = '8fbb61ea34d6f5d'; |
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; | |
my $ua = Mojo::UserAgent->new; | |
$ua->max_redirects(5); | |
my $base_url ='http://api.powerhousemuseum.com/api/v1/category/xml/'; | |
my $api_key = 'xxx'; | |
my $base_rest_url = Mojo::URL->new($base_url)->query({ api_key => $api_key}); |
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::URL; | |
my $url = Mojo::URL->new('http://example.com/?action=test'); | |
my $url2 = Mojo::URL->new('broker.js?foo=bar'); | |
$url->path($url2->path); | |
$url->query($url2->query); | |
# http://example.combroker.js?foo=bar | |
# ^ ??? |
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 Mojolicious::Lite; | |
our $counter = 0; | |
app->secret('kashkgfsjgnscjzgang'); | |
app->config({ | |
hypnotoad => { | |
listen => ['http://*:8765'], |
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 | |
BEGIN { | |
unshift(@INC, | |
'home/me/cgi-bin/lib' # absolute path | |
}; | |
use Mojolicious::Lite; | |
my $count = 0; |
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 Mojolicious::Plugin::Filter2; | |
use Mojo::Base 'Mojolicious::Plugin'; | |
# Register plugin | |
sub register { | |
my ($plugin, $mojo) = @_; | |
my %filters; | |
# Filter helper |
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 Mojolicious::Plugin::Filter; | |
use Mojo::Base 'Mojolicious::Plugin'; | |
# Register plugin | |
sub register { | |
my ($plugin, $mojo) = @_; | |
my %filters; | |
# Filter helper |
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
# Some values. | |
my ($a, $b, $c) = ('hallo', 'foo', 'bar'); | |
# Emit a filter hook | |
$c->filter( | |
'on_database_access' => | |
\$a, \$b, \$c => | |
sub { # Do whenever all subscribers are done. | |
print $a,"\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
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
get '/' => sub { | |
my $c = shift; | |
$c->res->headers->content_length(5); | |
$c->write( | |
'Hallo' => sub { | |
my $c = shift; | |
sleep(3); |
NewerOlder