Skip to content

Instantly share code, notes, and snippets.

View Akron's full-sized avatar

Nils Diewald Akron

View GitHub Profile
@Akron
Akron / gist:1265535
Created October 5, 2011 20:09
Tidy up when guests are gone
#!/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);
@Akron
Akron / gist:1216847
Created September 14, 2011 15:16
Render in advance
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');
use Mojolicious::Routes;
my $r = Mojolicious::Routes->new('/(:user)');
print join(',',@{$r->pattern->symbols});
@Akron
Akron / gist:1164293
Created August 23, 2011 03:39
Add_shortcut goes wrong ...?
#/usr/bin/env perl
package Test;
use Mojo::Base 'Mojolicious';
sub startup {
my $m = shift;
my $r = $m->routes;
$r->add_shortcut(
@Akron
Akron / gist:1014751
Created June 8, 2011 16:20
Sample Mojo-App with route-Shortcut
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?
@Akron
Akron / Mojolicious::Plugin::Wordlist.pm
Created May 19, 2011 16:46
Unexpected behaviour when reregistering plugins
package Mojolicious::Plugin::Wordlist;
use Mojo::Base 'Mojolicious::Plugin';
sub register {
my ($plugin, $mojo) = @_;
$plugin->{text} = "Wordlist:\n";
$mojo->helper(
'words' => sub {