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::Wordlist; | |
use Mojo::Base 'Mojolicious::Plugin'; | |
sub register { | |
my ($plugin, $mojo) = @_; | |
$plugin->{text} = "Wordlist:\n"; | |
$mojo->helper( | |
'words' => sub { |
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::Test; | |
use Mojo::Base 'Mojolicious::Plugin'; | |
sub register { | |
my ($plugin, $mojo) = @_; | |
$mojo->routes->add_shortcut( | |
'test' => sub { | |
my $route = shift; | |
$route->name('test'); | |
# What are the wildcards? |
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 | |
package Test; | |
use Mojo::Base 'Mojolicious'; | |
sub startup { | |
my $m = shift; | |
my $r = $m->routes; | |
$r->add_shortcut( |
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::Routes; | |
my $r = Mojolicious::Routes->new('/(:user)'); | |
print join(',',@{$r->pattern->symbols}); |
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 '/' => sub { | |
my $c = shift; | |
$c->write_chunk('hi', | |
sub { | |
# New c not necessary | |
$c->finish; | |
sleep(3); | |
$c->app->log->debug('check'); |
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->render_text('Hallo!'); | |
$c->on_finish( | |
sub { | |
my $c = shift; | |
sleep(3); |
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); |
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
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
package Mojolicious::Plugin::Filter2; | |
use Mojo::Base 'Mojolicious::Plugin'; | |
# Register plugin | |
sub register { | |
my ($plugin, $mojo) = @_; | |
my %filters; | |
# Filter helper |
OlderNewer