.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Dancer2::Core::Response::Delayed 3pm" .TH Dancer2::Core::Response::Delayed 3pm "2023-12-15" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Dancer2::Core::Response::Delayed \- Delayed responses .SH "VERSION" .IX Header "VERSION" version 1.1.0 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& my $response = Dancer2::Core::Response::Delayed\->new( \& request => Dancer2::Core::Request\->new(...), \& response => Dancer2::Core::Response\->new(...), \& cb => sub {...}, \& \& # optional error handling \& error_cb => sub { \& my ($error) = @_; \& ... \& }, \& ); \& \& # or in an app \& get \*(Aq/\*(Aq => sub { \& # delayed response: \& delayed { \& # streaming content \& content "data"; \& content "more data"; \& \& # close user connection \& done; \& } on_error => sub { \& my ($error) = @_; \& warning \*(AqFailed to stream to user: \*(Aq . request\->remote_address; \& }; \& }; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This object represents a delayed (asynchronous) response for Dancer2. It can be used via the \f(CW\*(C`delayed\*(C'\fR keyword. .PP It keeps references to a request and a response in order to avoid keeping a reference to the application. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" .SS "request" .IX Subsection "request" Contains a request the delayed response uses. .PP In the context of a web request, this will be the request that existed when the delayed response has been created. .SS "response" .IX Subsection "response" Contains a response the delayed response uses. .PP In the context of a web request, this will be the response that existed when the delayed response has been created. .SS "cb" .IX Subsection "cb" The code that will be run asynchronously. .SS "error_cb" .IX Subsection "error_cb" A callback for handling errors. This callback receives the error as its first (and currently only) parameter. .SH "METHODS" .IX Header "METHODS" .SS "is_halted" .IX Subsection "is_halted" A method indicating whether the response has halted. .PP This is useless in the context of an asynchronous request so it simply returns no. .PP This method is likely going away. .SS "has_passed" .IX Subsection "has_passed" A method indicating whether the response asked to skip the current response. .PP This is useless in the context of an asynchronous request so it simply returns no. .PP This method is likely going away. .SS "to_psgi" .IX Subsection "to_psgi" Create a \s-1PSGI\s0 response. The way it works is by returning a proper \s-1PSGI\s0 response subroutine which localizes the request and response (in case the callback wants to edit them without a reference to them), and then calls the callback. .PP Finally, when the callback is done, it asks the response (whether it was changed or not) to create its own \s-1PSGI\s0 response (calling \f(CW\*(C`to_psgi\*(C'\fR) and sends that to the callback it receives as a delayed response. .SH "AUTHOR" .IX Header "AUTHOR" Dancer Core Developers .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2023 by Alexis Sukrieh. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.