PET::ActionMapper |
Class to map URI-s to ACTION-s. That is: the URI of the incoming (HTTP) requests are mapped to Perl object method calls. For example, you can map http://youriste.com/foobar.pet to YourClass->ACTION_foobar()
This is the base class, it cannot be used directly: real mapping is done by subclasses, e.g. PET::ActionMapper::Subdir.
The main config file defines which ActionMapper is used by the site at “actionmapper/class”. An instance of the named actionmapper is created at init time when the PET application is started, and the “init” method is called. The “call” method is called subsequently when there is an incoming request.
Subclasses should override the resolveCall method, which does the real mapping.
This class also does the creation of objects from you API(s).
By default, there is no actionmapping -- your .pet files are processed as “simple” TT templates.
This assumes that you have your own modules (API-s) in $BASEDIR/modules. This cannot be overriden.
| PET:: | Class to map URI-s to ACTION-s. |
| Variables | |
| $DISP | An instance of PET::Dispatcher. |
| $LOG | An instance of PET::Logger. |
| $modulesdir | Set at init time, stores “$BASEPATH/modules” for later usage (module repository). |
| %APISTORE | We store instanteniated api objects here. |
| Functions | |
| new ($class) | Instanteniate class. |
| init ($disp) | Inits class. |
| call ($uri) | $uri -- the REQUEST_URI |
| resolveCall ($uri) | This method does the real URI-to-method mapping. |
sub init
Inits class. Sets $DISP, $LOG and $modulesdir.
$disp -- a PET::Dispatcher instance
Returns: -
sub call
$uri -- the REQUEST_URI
{ ‘subst’ => \%hash | $string, ‘gsubst’ => { ...} }
Called by PET::Dispatcher when there is an incoming request.
An instance of PET::Dispatcher.
my $DISP
An instance of PET::Logger.
my $LOG
Set at init time, stores “$BASEPATH/modules” for later usage (module repository).
our $modulesdir
We store instanteniated api objects here.
our %APISTORE
Instanteniate class.
sub new
Inits class.
sub init
$uri -- the REQUEST_URI
sub call
This method does the real URI-to-method mapping.
sub resolveCall