Kelp::Module::Routes - Default router module for Kelp
# config.pl { modules => ['Routes'], # included by default modules_init => { Routes => { base => 'MyApp' } } } # lib/MyApp.pm sub build { my $self = shift; mt $self->add_route( '/', 'home' ); }
This module and Kelp::Module::Config are automatically loaded into each Kelp application. It initializes the routing table for the web application.
This module registers the following methods into the underlying app:
An instance to Kelp::Routes, or whichever router was specified in the configuration.
# lib/MyApp.pm sub build { my $self = shift; $self->routes->add( '/', 'home' ); }
A shortcut to the "add" in Kelp::Routes method.
The configuration for this module containes the following keys:
The router class to use. The default value is Kelp::Routes, but any other class can be specified. A normal string will be considered a subclass of Kelp::Routes, for example:
Kelp::Routes
router => 'Custom'
will look for Kelp::Routes::Custom. To specify a fully qualified class, prefix it with a plus sign.
Kelp::Routes::Custom
router => '+My::Special::Router
See Kelp::Routes::Controller for a router class that reblesses the application instance.
Specifies the base class of each route. This saves a lot of typing when writing the routes definitions.
base => 'MyApp'
Now when defining a route you can only type 'myroute' to denote 'MyApp::myroute'.
To install Kelp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Kelp
CPAN shell
perl -MCPAN -e shell install Kelp
For more information on module installation, please visit the detailed CPAN module installation guide.