The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

CatalystX::Controller::Sugar::ActionPack::Default

DESCRIPTION

This module acts as a default handler for a controller. It will either server a file by its best knowledge or do go('/error', ["not_found"]).

DEPENDENCIES

CatalystX::Controller::Sugar::ActionPack::Error or an /error action.

SAMPLE CONFIG FILE

 <Controller::Foo>
   serve_static robots.txt
   serve_static foo/bar.png
 </Controller::Foo>

The example above requires this module to be injected into the Root controller.

It will allow the default action to serve files relative to the root/ folder. "robots.txt" will therefor be translated to:

 /path/to/my-project/root/robots.txt

ACTIONS

Endpoint /*

 go '/', [@path];

Will serve a static file by these rules:

 1) Exists root/@path.tt
 2) Exists root/@path/default.tt
 3) Is the requested file defined in config file

Will go() to /error unless the rules match the request.

LICENSE

AUTHOR

See CatalystX::Controller::Sugar::ActionPack.