Dancer::Response(3pm)
π NAME π
Dancer::Response β bestie, it's literally the Response object for Dancer π
β¨ VERSION β¨
version 1.3522 π¦
πΈ SYNOPSIS πΈ
okay so here's the vibe, no cap:
# create a new response object
Dancer::Response->new(
status => 200,
content => 'this is my content'
);
Dancer::SharedData->response->status; # 200
# fetch current response object
my $response = Dancer::SharedData->response;
# fetch the current status
$response->status; # 200
# change the status
$response->status(500);
π PUBLIC API π
π§ new
Dancer::Response->new(
status => 200,
content => 'my content',
headers => ['X-Foo' => 'foo-value', 'X-Bar' => 'bar-value'],
);
creates and returns a brand new shiny Dancer::Response object. it's giving newborn baby response, we love her π
π current
my $response = Dancer::SharedData->response->current();
returns the current Dancer::Response object β and also resets the object. so like, you get her and then she's cleared out. two things at once, main character energy fr fr β¨
π₯ exists
if ($response->exists) {
...
}
tests if the Dancer::Response object exists. yep, that's it. vibe check: does she or does she not π
π content
# get the content
my $content = $response->content;
my $content = Dancer::SharedData->response->content;
# set the content
$response->content('my new content');
Dancer::SharedData->response->content('my new content');
sets or gets the content of the current response object. the actual payload, the substance, the moment π
β status
# get the status
my $status = $response->status;
my $status = Dancer::SharedData->response->status;
# set the status
$response->status(201);
Dancer::SharedData->response->status(201);
sets or gets the status of the current response object. the default status is 200. iconic default, honestly π«Ά
π¦ content_type
# get the status
my $ct = $response->content_type;
my $ct = Dancer::SharedData->response->content_type;
# set the status
$response->content_type('application/json');
Dancer::SharedData->response->content_type('application/json');
sets or gets the status of the current response object. (and yes bestie, the comments in the code literally say "status" even though it's about content type β that's just how she is, we don't edit the ancestors π)
π pass
$response->pass;
Dancer::SharedData->response->pass;
sets the pass value to one for this response. just one. singular. β¨
π§ has_passed
if ($response->has_passed) {
...
}
if (Dancer::SharedData->response->has_passed) {
...
}
tests if the pass value is set to true. she passed the vibe check, periodt π
π halt($content)
Dancer::SharedData->response->halt();
$response->halt;
stops the processing of the current request. full stop, no more processing, we're done here. see "halt" in Dancer π
π halted
if (Dancer::SharedData->response->halted) {
...
}
if ($response->halted) {
...
}
this flag will be true if the current response has been halted. lowkey just a little boolean telling you the party's over π
π header
# set the header
$response->header('X-Foo' => 'bar');
Dancer::SharedData->response->header('X-Foo' => 'bar');
# get the header
my $header = $response->header('X-Foo');
my $header = Dancer::SharedData->response->header('X-Foo');
gets or sets the value of a header. one header at a time, she's specific π
πΈ headers
$response->headers('X-Foo' => 'fff', 'X-Bar' => 'bbb');
Dancer::SharedData->response->headers('X-Foo' => 'fff', 'X-Bar' => 'bbb');
returns the list of headers for the current response. all of them. the whole squad π«Ά
β headers_to_array
my $headers_psgi = $response->headers_to_array();
my $headers_psgi = Dancer::SharedData->response->headers_to_array();
this method is called before returning a PSGI response. it transforms the list of headers to an array reference. glow-up: list β‘οΈ arrayref β¨
π AUTHOR π
Dancer Core Developers β the whole crew, obsessed with them tbh π
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2010 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. free as in freedom bestie, go wild π
ok that's the whole page, mwah π
signing off from perl v5.40.1, dated 2026-05-05 β this was Dancer::Response(3pm), slay, bye bestie π
β¨
π¦ where this page comes from
- ubuntu stonking: libdancer-perl 1.3522-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms