Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Dancer2: respond to client while making its own async call

by 1nickt (Canon)
on Apr 01, 2021 at 21:10 UTC ( #11130693=note: print w/replies, xml ) Need Help??


in reply to Dancer2: respond to client while making its own async call

Hi Steve

It's as simple as:

post '/blorgle' => sub { debug('Entering delayed handler'); delayed { my %params = params; flush; content '<html><body>ok</body></html>'; done; debug('Sent response'); # Do your async job here }; };

See Dancer2::Core::Response::Delayed, https://metacpan.org/pod/distribution/Dancer2/lib/Dancer2/Manual.pod#Delayed-responses-(Async/Streaming)

Hope this helps!


The way forward always starts with a minimal test.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11130693]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2022-07-07 11:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?