Skip to content

Commit

Permalink
use MyApp::MyController instead of MyApp::C in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 6, 2014
1 parent 64a3408 commit 13881d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -457,7 +457,7 @@ startup method to define the url endpoints for your application.
$r->post('/baz')->to('test#baz');
# Add another namespace to load controllers from
push @{$app->routes->namespaces}, 'MyApp::C';
push @{$app->routes->namespaces}, 'MyApp::MyController';
=head2 secrets
Expand Down
15 changes: 8 additions & 7 deletions lib/Mojolicious/Guides/Routing.pod
Expand Up @@ -315,21 +315,22 @@ dispatching to it.
You can use the C<namespace> stash value to change the namespace of a whole
route with all its children.

# /bye -> MyApp::C::Foo::Bar->bye
$r->route('/bye')->to(namespace => 'MyApp::C::Foo::Bar', action => 'bye');
# /bye -> MyApp::MyController::Foo::Bar->bye
$r->route('/bye')
->to(namespace => 'MyApp::MyController::Foo::Bar', action => 'bye');

The C<controller> is always appended to the C<namespace> if available.

# /bye -> MyApp::C::Foo::Bar->bye
$r->route('/bye')->to('foo-bar#bye', namespace => 'MyApp::C');
# /bye -> MyApp::MyController::Foo::Bar->bye
$r->route('/bye')->to('foo-bar#bye', namespace => 'MyApp::MyController');

# /hey -> MyApp::C::Foo::Bar->hey
$r->route('/hey')->to('Foo::Bar#hey', namespace => 'MyApp::C');
# /hey -> MyApp::MyController::Foo::Bar->hey
$r->route('/hey')->to('Foo::Bar#hey', namespace => 'MyApp::MyController');

You can also change the default namespaces for all routes in the application
with the router attribute L<Mojolicious::Routes/"namespaces">.

$r->namespaces(['MyApp::C']);
$r->namespaces(['MyApp::MyController']);

=head2 Route to callback

Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Routes.pm
Expand Up @@ -285,7 +285,7 @@ C<attr>, C<has>, C<new> and C<tap>.
Namespaces to load controllers from.
# Add another namespace to load controllers from
push @{$r->namespaces}, 'MyApp::C';
push @{$r->namespaces}, 'MyApp::MyController';
=head2 shortcuts
Expand Down

0 comments on commit 13881d2

Please sign in to comment.