NAME
Catalyst::Engine - The Catalyst Engine
SYNOPSIS
See Catalyst.
DESCRIPTION
METHODS
action
Add one or more actions.
$c->action( '!foo' => sub { $_[1]->res->output('Foo!') } );
Get an action's class and coderef.
my ($class, $code) = @{ $c->action('foo') };
Get a list of available actions.
my @actions = $c->action;
It also automatically calls setup() if needed.
We currently have four types of actions.
1. Normal actions:
$c->action( 'foo/bar' => sub { } );
Would match http://localhost:3000/foo/bar
2. Regex actions (surrounded by //):
$c->action( '/foo(\d+)/bar(\d+)/' => sub { } );
Would match http://localhost:3000/foo23/bar42
Extracted fragments (23, 42) are available in the $c->req->snippets array
3. Private actions (prefixed with !):
$c->action( '!foo' => sub { } );
Like normal actions, but only internal addressable by $c->forward('!foo')
There are also built in private actions with special meaning:
* !default - used when no other action matches
* !begin - called at the beginning of a request
* !end - called at the end of a request
4. Prefixed actions (prefixed with ?)
package MyApp::C::My::Controller;
$c->action( '?foo' => sub { } );
Would match http://localhost:3000/my_controller/foo
Like normal actions, but prefixed with a special moniker
benchmark
Takes a coderef with arguments and returns elapsed time as float.
my ( $elapsed, $status ) = $c->benchmark( sub { return 1 } );
$c->log->info( sprintf "Processing took %f seconds", $elapsed );
component (comp)
Get a component object by name.
$c->comp('MyApp::Model::MyModel')->do_stuff;
Regex search for a component.
$c->comp('mymodel')->do_stuff;
errors
Returns an arrayref containing errors messages.
my @errors = @{ $c->errors };
Add a new error.
$c->errors('Something bad happened');
finalize
Finalize request.
finalize_headers
Finalize headers.
finalize_output
Finalize output.
forward
Forward processing to a private/public action or a method from a class. If you define a class without method it will default to process().
$c->forward('!foo');
$c->forward('index.html');
$c->forward(qw/MyApp::Model::CDBI::Foo do_stuff/);
$c->forward('MyApp::View::TT');
handler
Handles the request.
prepare
Turns the request (Apache, CGI...) into a Catalyst context.
prepare_action
Prepare action.
prepare_cookies;
Prepare cookies.
prepare_headers
Prepare headers.
prepare_parameters
Prepare parameters.
prepare_path
Prepare path and base.
prepare_request
Prepare the engine request.
prepare_uploads
Prepare uploads.
process
Process a coderef in given class and catch exceptions. Errors are available via $c->errors.
remove_action
Remove an action.
$c->remove_action('!foo');
request (req)
Returns a Catalyst::Request
object.
my $req = $c->req;
response (res)
Returns a Catalyst::Response
object.
my $res = $c->res;
setup
Setup.
MyApp->setup;
setup_components
Setup components.
stash
Returns a hashref containing all your data.
$c->stash->{foo} ||= 'yada';
print $c->stash->{foo};
AUTHOR
Sebastian Riedel, sri@cpan.org
COPYRIGHT
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.