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 😭

# 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 πŸ‘‘

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