NAME

Kelp::Module::Routes - Default router module for Kelp

SYNOPSIS

# 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' );
}

DESCRIPTION

This module and Kelp::Module::Config are automatically loaded into each Kelp application. It initializes the routing table for the web application.

REGISTERED METHODS

This module registers the following methods into the underlying app:

routes

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' );
}

add_route

A shortcut to the "add" in Kelp::Routes method.

CONFIGURATION

The configuration for this module contains the following keys:

router

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:

router => 'Custom'

will look for Kelp::Routes::Custom. To specify a fully qualified class, prefix it with a plus sign.

router => '+My::Special::Router

configuration of the router

All other configuration is passed to the router. For the configuration of the default router, see "ATTRIBUTES" in Kelp::Routes.