[Catalyst] New Root Controller in Catalyst 5.66
Sebastian Riedel
sri at oook.de
Wed Mar 1 04:58:43 CET 2006
There has been a small change in trunk for the catalyst.pl generated
MyApp.pm.
MyApp.pm will no more contain actions, instead we have a
MyApp::Controller::Root now.
This is another best practice promoted to be part of core, it will
eliminate namespace collisions like for the famous "login" action in
combination with auth plugins. ;)
This change does not affect old code, it will all still just work.
A small example (without most comments and pod):
# MyApp.pm
package MyApp;
use strict;
use warnings;
use Catalyst qw/-Debug ConfigLoader Static::Simple/;
our $VERSION = '0.01';
__PACKAGE__->setup;
1;
# MyApp/Controller/Root.pm
package MyApp::Controller::Root;
use strict;
use warnings;
use base 'Catalyst::Controller';
#
# Sets the actions in this controller to be registered with no
prefix
# so they function identically to actions created in MyApp.pm
#
__PACKAGE__->config->{namespace} = '';
sub default : Private {
my ( $self, $c ) = @_;
# Hello World
$c->response->body( $c->welcome_message );
}
#sub end : Private {
# my ( $self, $c ) = @_;
#
# # Forward to View unless response body is already defined
# $c->forward( $c->view('') ) unless $c->response->body;
#}
1;
--
sebastian
More information about the Catalyst
mailing list