Skip to content

Commit

Permalink
tweaked routing examples a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 29, 2012
1 parent 9f7a012 commit 4bbfa21
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/Mojolicious/Command/generate/app.pm
Expand Up @@ -86,7 +86,7 @@ sub startup {
# Documentation browser under "/perldoc"
$self->plugin('PODRenderer');
# Routes
# Router
my $r = $self->routes;
# Normal route to controller
Expand Down
1 change: 0 additions & 1 deletion lib/Mojolicious/Guides/Growing.pod
Expand Up @@ -507,7 +507,6 @@ actual action code needs to be changed.
my $users = MyUsers->new;
$self->helper(users => sub { return $users });

# Routes
my $r = $self->routes;

$r->any('/' => sub {
Expand Down
16 changes: 4 additions & 12 deletions lib/Mojolicious/Guides/Routing.pod
Expand Up @@ -150,7 +150,7 @@ routes structures.
sub startup {
my $self = shift;

# Routes
# Router
my $r = $self->routes;

# Route
Expand Down Expand Up @@ -258,11 +258,8 @@ sensitive.
sub startup {
my $self = shift;

# Routes
my $r = $self->routes;

# /bye -> {controller => 'foo', action => 'bye'} -> MyApp::Foo->bye
$r->route('/bye')->to(controller => 'foo', action => 'bye');
$self->routes->route('/bye')->to(controller => 'foo', action => 'bye');
}

1;
Expand Down Expand Up @@ -534,10 +531,8 @@ which makes them a very powerful tool especially for plugins.
if $self->req->url->path->contains('/test');
});

# Routes
my $r = $self->routes;

# These will not be reached if the hook above renders a response
my $r = $self->routes;
$r->route('/welcome')->to('foo#welcome');
$r->route('/bye')->to('foo#bye');
}
Expand Down Expand Up @@ -724,11 +719,8 @@ applications.
# Plugin
$self->plugin('WerewolfCondition');

# Routes
my $r = $self->routes;

# /hideout (keep them out for 4 days after full moon)
$r->route('/hideout')->over(werewolf => 4)
$self->routes->route('/hideout')->over(werewolf => 4)
->to(controller => 'foo', action => 'bar');
}

Expand Down
4 changes: 1 addition & 3 deletions t/mojolicious/lib/MojoliciousTest.pm
Expand Up @@ -41,11 +41,9 @@ sub startup {
$self->sessions->cookie_domain('.example.com');
$self->sessions->cookie_path('/bar');

# Routes
my $r = $self->routes;

# /plugin/upper_case
# /plugin/camel_case (plugins loaded correctly)
my $r = $self->routes;
$r->route('/plugin/upper_case')->to('foo#plugin_upper_case');
$r->route('/plugin/camel_case')->to('foo#plugin_camel_case');

Expand Down
4 changes: 1 addition & 3 deletions t/mojolicious/routes.t
Expand Up @@ -6,10 +6,8 @@ use Test::More tests => 351;
use_ok 'Mojolicious::Routes';
use_ok 'Mojolicious::Routes::Match';

# Routes
my $r = Mojolicious::Routes->new;

# /clean
my $r = Mojolicious::Routes->new;
$r->route('/clean')->to(clean => 1);

# /clean/too
Expand Down

0 comments on commit 4bbfa21

Please sign in to comment.