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)


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