Dancer2...spatcher(3)
π Dancer2::Core::Dispatcher β the class that sends your request to the right route handler π
okay bestie, welcome to the Dancer2...spatcher(3) page from the User Contributed Perl Documentation β¨ this is Dancer2::Core::Dispatcher, the vibe-checker that figures out which route handler should get your request. it's giving air traffic control but make it Perl π¬
β¨ VERSION β¨
we're on version 2.2.1, no cap π«Ά
πΈ SYNOPSIS πΈ
here's the whole flex, copied exactly:
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($app, $error);
# Capture response not found for an application the after dispatch
$dispatcher->response_not_found($env);
π ATTRIBUTES π
π
apps
apps is an array reference pointing at Dancer2::Core::App objects. like, a whole little squad of apps, bestie π
π
default_content_type
default_content_type is a string that represents the context of the request. heads up though: this attribute is read-only, so don't try to change it, she said what she said π
π¦ METHODS π¦
β dispatch
the dispatch method takes in the list of applications, a hash reference for the env attribute of Dancer2::Core::Request, and optionally the request object and an env as input arguments. it's flexible like that π
dispatch hands you back a response object of Dancer2::Core::Response. iconic behavior, honestly.
and here's the spicy technical bit: any before hook and matched route code gets wrapped so that DSL keywords like forward and redirect can short-circuit the rest of the code β returning across multiple stack frames without having to throw an exception. yes bestie, no exception drama, we just vibe our way back up the stack π₯
β response_internal_error
response_internal_error takes as input the list of applications plus a variable error, and returns an object of Dancer2::Core::Error. catching L's gracefully, periodt π
β response_not_found
response_not_found consumes as input the list of applications and an object of type Dancer2::Core::App, and returns an object of Dancer2::Core::Error. so when the route doesn't exist, she still shows up with a proper 404-ish moment π
π AUTHOR π
Dancer Core Developers π (genuinely the main characters of this whole ecosystem)
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2026 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. slay, free software π«Ά
okay that's the whole page!! this was perl v5.42.3, dated 2026-09-20, and it's filed under Dancer2...spatcher(3). go dispatch something cute bestie πβ¨π
π¦ where this page comes from
- fedora 44: perl-Dancer2 2.2.1-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms