O'Reilly logo

Catalyst 5.8 by Antano Solar John

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Moose in Catalyst

The moosified version of our application (AddressBook.pm) from the previous chapter will look like the following code sample. You will need to moosify your application if you want to use any moosified plugin/role in your application.

package AddressBook;
use Moose;
use namespace::autoclean;
use Catalyst( qw/
ConfigLoader
Static::Simple
/);
$app->config( name => 'MyApp' );
$app->setup;
# If you want to make use of modifiers. You can do something like this
before finalize
{
# Do something here before the finalize of every response
};

As discussed earlier, before is the modifier and we can just ask Catalyst to run the last code before executing the finalize method.

The use of namespace::autoclean is a best practice, which cleans ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required