<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Aug 22, 2015 at 10:36 AM, Robert Smith <span dir="ltr"><<a href="mailto:spamfree@wansecurity.com" target="_blank">spamfree@wansecurity.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Here’s what I want to do:<br>
<br>
post '/info' => sub {<br>
info "\n\n\tIn /info with params:\n" . Dumper params;<br>
<br>
my $tmp_href = params;<br>
<br>
if (&do_some_stuff_here($tmp_href)) {<br>
$tmp_href->{status_code} = "200";<br>
}<br>
return $tmp_href;<br>
<br>
# THEN DO SOME POST RETURN STUFF HERE (Obviously not here, but somehow a callback function for post-return or something like that?)<br>
<br>
};<br>
<br>
Does it exist? I feel like I’ve been through the documentation pretty thoroughly.<br>
<br>
-Robert<br></blockquote><div><br></div><div>It seems like you could achieve what you want by using fork:</div><div><br></div><div><font face="monospace, monospace"> post '/info' => sub {</font></div><div><font face="monospace, monospace"> my $tmp_href = params;</font></div><div><font face="monospace, monospace"> # ...</font></div><div><font face="monospace, monospace"> my $pid = fork;</font></div><div><font face="monospace, monospace"> if ($pid) {</font></div><div><font face="monospace, monospace"> return $tmp_href;</font></div><div><font face="monospace, monospace"> } else {</font></div><div><font face="monospace, monospace"> # DO SOME POST RETURN STUFF HERE</font></div><div><font face="monospace, monospace"> }</font></div><div><font face="monospace, monospace"> };</font></div><div><br></div><div>Your tmp_href response would return immediately, but a child process would keep running in the background doing your POST RETURN STUFF.</div><div><br></div><div>Though the proper way to do something like this is with some sort of a messaging/worker system. See for example:</div><div><a href="https://metacpan.org/pod/Dancer::Plugin::Stomp">https://metacpan.org/pod/Dancer::Plugin::Stomp</a></div><div><a href="https://metacpan.org/pod/POE::Component::MessageQueue">https://metacpan.org/pod/POE::Component::MessageQueue</a></div><div><br></div><div>-Naveed</div></div></div></div>