Skip to content

Instantly share code, notes, and snippets.

@Akron
Created June 8, 2011 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Akron/1014751 to your computer and use it in GitHub Desktop.
Save Akron/1014751 to your computer and use it in GitHub Desktop.
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?
$route->to(
cb => sub {
my $c = shift;
$c->render_data(
'Yeah ... '.
$c->url_for('test')->to_abs .
' vs '.
$c->url_for('current')->to_abs
);
}
);
}
);
};
package Application;
use Mojo::Base 'Mojolicious';
sub startup {
my $mojo = shift;
$mojo->plugin('test');
my $r = $mojo->routes;
$r->route('/:user/:foo/')->test;
};
package main;
Application->start;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment