[dancer-users] Does dancer have a post-return hook or something of that nature?

Robert Smith spamfree at wansecurity.com
Mon Aug 24 01:08:19 BST 2015

It’s for an API I wrote for the ZeroKnowledge Foundation. It allows the customer to pass nothing more than an ID, and we spin up a VM for them, and they get nothing more than an IP address to hand to their customers. After each call, for /create (spin up) I work our magic and get a new VM setup for them and pass them back an IP address returning status 200. While waiting for their next create call, in the background I want to clone a disk image which takes several minutes to complete. I’d like something more elegant than writing a file somewhere and having a background task to the copy. In fact, I’d like to even have the API block while the background copy process is working.

But what I’m really trying to figure out is some kind of callback function to allow me to execute something after the return. Like a post-return callback.


> On Aug 23, 2015, at 5:47 AM, John Stoffel <john at stoffel.org> wrote:
>>>>>> "Robert" == Robert Smith <spamfree at wansecurity.com> writes:
> Robert> Here’s what I want to do:
> Robert> post '/info' => sub {
> Robert>         info "\n\n\tIn /info with params:\n" . Dumper params;
> Robert> 	my $tmp_href = params;
> Robert>   	if (&do_some_stuff_here($tmp_href)) {
> Robert>                 $tmp_href->{status_code}        = "200";		
> Robert> 	}
> Robert> 	return $tmp_href;
> Robert> 	# THEN DO SOME POST RETURN STUFF HERE (Obviously not
> Robert> 	here, but somehow a callback function for post-return
> Robert> 	or something like that?)
> Well... you can't do anything in a function after a return gets
> called, so you will have to setup a callback function.  What are you
> trying to do in the callback?  
> Before the return $tmp_ref; you need to put in a call to something
> else, which could just be a POST to another URL.  Or if it's a longer
> lived process (say you're kicking off a job to process all the params
> you passed in), then maybe what you want to do is really return a DIV
> and some javascript which will poll looking for updates, etc.
> Sorta like how some of the pagination stuff works.  Sorry I'm not
> being very specific here, I'd be pounding my head too.  :-)
> John
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

More information about the dancer-users mailing list