Skip to content

Commit

Permalink
do not use bridge terminology in documentation anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 5, 2014
1 parent 6aef763 commit f2b7a95
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,5 +1,6 @@

5.38 2014-09-05
- Improved routes command to use new terminology for flags.

5.37 2014-09-03
- Improved Mojo::Template performance slightly.
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Command/routes.pm
Expand Up @@ -28,9 +28,9 @@ sub _walk {

# Flags
my @flags;
push @flags, $route->inline ? 'B' : '.';
push @flags, @{$route->over || []} ? 'C' : '.';
push @flags, (my $partial = $route->partial) ? 'D' : '.';
push @flags, $route->inline ? 'U' : '.';
push @flags, $route->is_websocket ? 'W' : '.';
push @$row, join('', @flags) if $verbose;

Expand Down Expand Up @@ -68,7 +68,7 @@ Mojolicious::Command::routes - Routes command
Options:
-v, --verbose Print additional details about routes, flags indicate
B=Bridge, C=Conditions, D=Detour and W=WebSocket.
C=Conditions, D=Detour, U=Under and W=WebSocket.
=head1 DESCRIPTION
Expand Down
19 changes: 9 additions & 10 deletions lib/Mojolicious/Guides/Routing.pod
Expand Up @@ -493,20 +493,22 @@ is fine though.
This way you get easily readable routes and the raw power of regular
expressions.

=head2 Bridges
=head2 Under

Bridge routes created with the method L<Mojolicious::Routes::Route/"under">
can be used to share code with multiple nested routes, because unlike normal
nested routes, they result in additional dispatch cycles when they match.
To share code with multiple nested routes you can use
L<Mojolicious::Routes::Route/"under">, because unlike normal nested routes,
routes generated with it have their own destination and result in additional
dispatch cycles when they match.

# /foo -> undef
# /foo/bar -> {controller => 'foo', action => 'baz'}
# {controller => 'foo', action => 'bar'}
my $foo = $r->under('/foo')->to('foo#baz');
$foo->get('/bar')->to('#bar');

The actual bridge code needs to return a true value or the dispatch chain will
be broken, this makes bridges a very powerful tool for authentication.
The actual action code for this destination needs to return a true value or
the dispatch chain will be broken, this can be a very powerful tool for
authentication.

# /foo/bar -> {cb => sub {...}}
# {controller => 'foo', action => 'bar'}
Expand Down Expand Up @@ -733,9 +735,6 @@ to make route generation more expressive.
# OPTIONS /user -> {cb => sub {...}}
$r->resource('user');

Shortcuts can lead to anything, routes, bridges or maybe even both. And watch
out for quicksand!

=head2 Introspection

The command L<Mojolicious::Command::routes> can be used from the command line
Expand All @@ -744,7 +743,7 @@ expressions.

$ ./myapp.pl routes -v
/foo/:name .... POST fooname ^/foo/([^/\.]+) ^/?(?:\.([^/]+))?$
/bar B... * bar ^/bar
/bar ..U. * bar ^/bar
+/baz ...W GET baz ^/baz ^/?(?:\.([^/]+))?$
/yada .... * yada ^/yada ^/?(?:\.([^/]+))?$

Expand Down
14 changes: 7 additions & 7 deletions lib/Mojolicious/Lite.pm
Expand Up @@ -534,8 +534,8 @@ is fine though.
=head2 Under
Authentication and code shared between multiple routes can be realized easily
with bridge routes generated by the L</"under"> statement. All following
routes are only evaluated if the callback returned a true value.
with routes generated by the L</"under"> statement. All following routes are
only evaluated if the callback returned a true value.
use Mojolicious::Lite;
Expand Down Expand Up @@ -1126,12 +1126,12 @@ requests. See also the tutorial above for many more argument variations.
=head2 under
my $bridge = under sub {...};
my $bridge = under '/:foo' => sub {...};
my $bridge = under '/:foo' => [foo => qr/\w+/];
my $bridge = under {format => 0};
my $route = under sub {...};
my $route = under '/:foo' => sub {...};
my $route = under '/:foo' => [foo => qr/\w+/];
my $route = under {format => 0};
Generate bridge route with L<Mojolicious::Routes::Route/"under">, to which all
Generate nested route with L<Mojolicious::Routes::Route/"under">, to which all
following routes are automatically appended. See also the tutorial above for
more argument variations.
Expand Down
27 changes: 14 additions & 13 deletions lib/Mojolicious/Routes/Route.pm
Expand Up @@ -267,7 +267,7 @@ The children of this route, used for nesting routes.
my $bool = $r->inline;
$r = $r->inline($bool);
Allow L</"bridge"> semantics for this route.
Allow L</"under"> semantics for this route.
=head2 parent
Expand Down Expand Up @@ -321,13 +321,13 @@ more argument variations.
=head2 bridge
my $bridge = $r->bridge;
my $bridge = $r->bridge('/:action');
my $bridge = $r->bridge('/:action', action => qr/\w+/);
my $bridge = $r->bridge(format => 0);
my $route = $r->bridge;
my $route = $r->bridge('/:action');
my $route = $r->bridge('/:action', action => qr/\w+/);
my $route = $r->bridge(format => 0);
Low-level generator for bridge routes, returns a L<Mojolicious::Routes::Route>
object.
Low-level generator for nested routes with their own intermediate destination,
returns a L<Mojolicious::Routes::Route> object.
my $auth = $r->bridge('/user')->to('user#auth');
$auth->get('/show')->to('#show');
Expand Down Expand Up @@ -557,13 +557,14 @@ Stringify the whole route.
=head2 under
my $bridge = $r->under(sub {...});
my $bridge = $r->under('/:foo' => sub {...});
my $bridge = $r->under('/:foo' => [foo => qr/\w+/]);
my $bridge = $r->under({format => 0});
my $route = $r->under(sub {...});
my $route = $r->under('/:foo' => sub {...});
my $route = $r->under('/:foo' => [foo => qr/\w+/]);
my $route = $r->under({format => 0});
Generate L<Mojolicious::Routes::Route> object for bridge route. See also the
L<Mojolicious::Lite> tutorial for many more argument variations.
Generate L<Mojolicious::Routes::Route> object for a nested route with its own
intermediate destination. See also the L<Mojolicious::Lite> tutorial for many
more argument variations.
my $auth = $r->under('/user')->to('user#auth');
$auth->get('/show')->to('#show');
Expand Down

0 comments on commit f2b7a95

Please sign in to comment.