Skip to content

Instantly share code, notes, and snippets.

@kraih
Created February 14, 2011 04:43
Show Gist options
  • Save kraih/825495 to your computer and use it in GitHub Desktop.
Save kraih/825495 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use Mojolicious::Routes;
use Mojolicious::Routes::Match;
# Create some routes
my $r = Mojolicious::Routes->new;
$r->get('/:action')->to(controller => 'foo');
# Match method and path against routes
my $m = Mojolicious::Routes::Match->new(GET => '/bar')->match($r);
# Results
print $m->captures->{controller}, "\n";
print $m->captures->{action}, "\n";
# Generate path from route
print $m->path_for(action => 'baz'), "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment