On Sat, Aug 22, 2015 at 10:36 AM, Robert Smith <[email protected]>
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
_______________________________________________
dancer-users mailing list
[email protected]
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users