NAME

Slick::RouteMap

SYNOPSIS

Slick::Router is a Slick::EventHandler and a Slick::RouteManager.

It is the primary object for defining routes, outside of the main Slick instance. If you want to spread routing logic out across multiple files, you'll want to export a Slick::Router from each module you want to contain routing logic.

Example

my $router = Slick::Router->new(base => '/foo'); # All routes will start with /foo

my $slick = Slick->new;

$router->get('/bob' => sub { my ($app, $context) = @_; $context->json({hello => 'world'}); });

# You may also add events that will be dispatched between global and route level events as well.
$router->on(before_dispatch => sub { my ($app, $context) = @_; return 1; });

$slick->register($router); # Register router with your Slick application

API

See Slick::EventHandler and Slick::RouteManager.

See also