With Catalyst you register your actions and address them directly. For
example:
- sub hello : Global {
+ sub hello : Local {
my ( $self, $context ) = @_;
$context->response->body('Hello World!');
}
Now http://localhost:3000/hello prints "Hello World!".
-Note that actions with the C< :Local > attribute are equivalent to
-using a C<:Path('/action_name') > attribute (note the leading slash).
-So our action could be equivalently:
+Note that actions with the C< :Global > attribute are equivalent to
+using a C<:Path('action_name') > attribute, so our action could be
+equivalently:
- sub hello : Path('/hello') {
+ sub hi : Path('hello') {
my ( $self, $context ) = @_;
$context->response->body('Hello World!');
}
use strict;
use parent qw/Catalyst/;
- __PACKAGE__->setup(qw/-Debug ConfigLoader Static::Simple/);
- # note you can still use use Catalyst qw/@plugins/ instead of the
- # above two lines
+ use Catalyst qw/-Debug ConfigLoader Static::Simple/;
MyApp->config(
name => 'My Application',
=head4 Built-in actions in controllers/autochaining
- Package MyApp::Controller::Foo;
+ package MyApp::Controller::Foo;
sub begin : Private { }
sub default : Path { }
sub auto : Private { }
=item for a request for C</foo/foo>
- MyApp::begin
- MyApp::auto
+ MyApp::Controller::Foo::auto
MyApp::Controller::Foo::default # in the absence of MyApp::Controller::Foo::Foo
- MyApp::end
+ MyApp::Controller::Foo::end
=item for a request for C</foo/bar/foo>
MyApp::Controller::Foo::Bar::begin
- MyApp::auto
MyApp::Controller::Foo::auto
MyApp::Controller::Foo::Bar::auto
MyApp::Controller::Foo::Bar::default # for MyApp::Controller::Foo::Bar::foo
false
MyApp::Controller::Foo::Bar::begin
- MyApp::auto
MyApp::Controller::Foo::Bar::end
=back