GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  DANCER2::CORE::RESPONSE::DELAYED (3)

.ds Aq ’

NAME

Dancer2::Core::Response::Delayed - Delayed responses

CONTENTS

VERSION

version 0.166001

SYNOPSIS



    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 / => sub {
        # delayed response:
        delayed {
            # streaming content
            content "data";
            content "more data";

            # close user connection
            done;
        } on_error => sub {
            my ($error) = @_;
            warning Failed to stream to user:  . request->remote_address;
        };
    };



DESCRIPTION

This object represents a delayed (asynchronous) response for Dancer2. It can be used via the delayed keyword.

It keeps references to a request and a response in order to avoid keeping a reference ot the application.

ATTRIBUTES

    request

Contains a request the delayed response uses.

In the context of a web request, this will be the request that existed when the delayed response has been created.

    response

Contains a response the delayed response uses.

In the context of a web request, this will be the response that existed when the delayed response has been created.

    cb

The code that will be run asynchronously.

    error_cb

A callback for handling errors. This callback receives the error as its first (and currently only) parameter.

METHODS

    is_halted

A method indicating whether the response has halted.

This is useless in the context of an asynchronous request so it simply returns no.

This method is likely going away.

    has_passed

A method indicating whether the response asked to skip the current response.

This is useless in the context of an asynchronous request so it simply returns no.

This method is likely going away.

    to_psgi

Create a PSGI response. The way it works is by returning a proper PSGI 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.

Finally, when the callback is done, it asks the response (whether it was changed or not) to create its own PSGI response (calling to_psgi) and sends that to the callback it receives as a delayed response.

AUTHOR

Dancer Core Developers

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 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.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 DANCER2::CORE::RESPONSE::DELAYED (3) 2016-01-22

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.