Dancer2...Response(3)
π NAME π
Dancer2::Core::Response β the response object for Dancer2, bestie. It's the lil' glow-up your app sends back to the world, and it lives in section 3 of the User Contributed Perl Documentation, iykyk. π¦
β¨ VERSION β¨
version 2.2.1 β yes she's current, no cap. π
π ATTRIBUTES π
Okay so these are the lil' properties she carries around, her whole personality fr:
is_encodedβ flag that tells you if the content has already been encoded. Once she's encoded, she's encoded. Periodt.is_haltedβ flag saying whether or not the response should keep being processed. Basically her "I'm done here" switch. πstatusβ the HTTP status for the response. The 200, the 404, the whole vibe check. β¨contentβ the actual content of the response, stored as a string. And listen, if you pass it a reference, she will try to coerce it into a string via double quote interpolation. She's flexible like that. πββοΈdefault_content_typeβ the default mime type she uses for the responseContent-Typeheader when nothing else was specified. Her fallback fit. πcharsetβ the charset used when encoding"text/*"responses. An empty value disables automatic encoding. So like, don't leave it blank unless you mean it. πheadersβ the attribute that stores the headers in anHTTP::Headers::Fastobject. She coerces fromArrayRefand defaults to an emptyHTTP::Headers::Fastinstance. Iconic behavior honestly. π
πΈ METHODS πΈ
π pass
Sets has_passed to true. That's it, that's the method. She passed, slay. β
π serializer()
Returns the optional serializer object used to deserialize request parameters. Your data's little translator. π«Ά
π halt
A shortcut to halt the current response by setting the is_halted flag. Emergency brake energy, but make it cute. π
π encode_content
Encodes the stored content according to the stored content_type. But if the content_type is not a text format "^text", then no encoding will take place. She knows when to sit this one out.
Internally, she uses the is_encoded flag to make sure content is never encoded twice. No double-dipping bestie, we don't do that. π
If she does encode the content, she'll return the encoded content. In all other cases she returns "false".
π new_from_plack
Creates a brand new response object from a Plack::Response object. Glow-up from scratch. β¨
π new_from_array
Creates a new response object from a PSGI arrayref. π«
π to_psgi
Converts the response object into a PSGI array. The reverse lil' transformation. π
π content_type($type)
A little sugar for setting or accessing the content_type of the response, via the headers. Just a lil' sweetener, nothing deep. π
π redirect ($destination, $status)
Sets a header in this response to give a redirect to $destination, and sets the status to $status. If $status is omitted, or false, then it defaults to a status of 302. Bye bestie, we're going elsewhere. π
π error( @args )
$response->error( message => "oops" );
Creates a Dancer2::Core::Error object with the given @args and throw()s it against the response object. Returns the error object. She's dramatic but she's organized. π
π serialize( $content )
$response->serialize( $content );
Serialize and return $content with the response's serializer. Sets content-type accordingly. π
π header($name)
Return the value of the given header, if present. And okay here's the nuance: if the header has multiple values, she returns the list of values when called in list context, and just the first one when called in scalar context. Know your context bestie, it matters. π§
π push_header
Add the header no matter if it already exists or not. She does not care. She adds it anyway. π
$self->push_header( 'X-Wing' => '1' );
She can also be called with multiple values to add the same header many times with different values:
$self->push_header( 'X-Wing' => 1, 2, 3 );
Multiple values? Multiple headers? Yes and yes. π₯
π headers_to_array($headers)
Convert the $headers to a PSGI ArrayRef.
If no $headers are provided, she'll use the current response headers instead. Convenient queen. π
π AUTHOR π
Dancer Core Developers. The whole squad. π«Ά
π 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. Free as in freedom bestie, go wild. π
And that's the whole page, no skips, no summaries. π
This has been Dancer2...Response(3) from the User Contributed Perl Documentation, generated by perl v5.42.3 on 2026-09-20. Stay slay, stay halted only when you mean it. πβ¨π
π¦ 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