[dancer-users] Does dancer have a post-return hook or something of that nature?
Naveed Massjouni
naveedm9 at gmail.com
Sun Aug 23 08:35:58 BST 2015
On Sat, Aug 22, 2015 at 10:36 AM, Robert Smith <spamfree at wansecurity.com>
wrote:
> Here’s what I want to do:
>
> post '/info' => sub {
> info "\n\n\tIn /info with params:\n" . Dumper params;
>
> my $tmp_href = params;
>
> if (&do_some_stuff_here($tmp_href)) {
> $tmp_href->{status_code} = "200";
> }
> return $tmp_href;
>
> # THEN DO SOME POST RETURN STUFF HERE (Obviously not here, but
> somehow a callback function for post-return or something like that?)
>
> };
>
> Does it exist? I feel like I’ve been through the documentation pretty
> thoroughly.
>
> -Robert
>
It seems like you could achieve what you want by using fork:
post '/info' => sub {
my $tmp_href = params;
# ...
my $pid = fork;
if ($pid) {
return $tmp_href;
} else {
# DO SOME POST RETURN STUFF HERE
}
};
Your tmp_href response would return immediately, but a child process would
keep running in the background doing your POST RETURN STUFF.
Though the proper way to do something like this is with some sort of a
messaging/worker system. See for example:
https://metacpan.org/pod/Dancer::Plugin::Stomp
https://metacpan.org/pod/POE::Component::MessageQueue
-Naveed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150823/a9c70c42/attachment.html>
More information about the dancer-users
mailing list