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 up the imported functions from the namespace.