NAME

Dancer2::Core::Dispatcher - Class for dispatching request to the appropriate route handler

VERSION

version 0.10

SYNOPSIS

use Dancer2::Core::Dispatcher;

# Create an instance of dispatcher
my $dispatcher = Dancer2::Core::Dispatcher->new( apps => [$app] );

# Dispatch a request
my $resp = $dispatcher->dispatch($env)->to_psgi;

# Capture internal error of a response (if any) after a dispatch
$dispatcher->response_internal_error($context, $error);

# Capture response not found for an application the after dispatch
$dispatcher->response_not_found($context);

ATTRIBUTES

apps

The apps is an array reference to Dancer2::Core::App.

default_content_type

The default_content_type is a string which represents the context of the request. This attribute is read-only.

METHODS

dispatch

The method dispatch accepts the list of applications, hash reference of the attribute env of Dancer2::Core::Request and request as input arguments.

dispatch returns a response object of Dancer2::Core::Response.

response_internal_error

The response_internal_error takes as input the list of applications and a variable error and returns an object of Dancer2::Core::Error.

response_not_found

The response_not_found consumes as input the list of applications and an object of type Dancer2::Core::Context and returns an object Dancer2::Core::Error.

AUTHOR

Dancer Core Developers

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Alexis Sukrieh.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.