[dancer-users] Migrating CGI.pm-based code to Dancer2
aireland at lbl.gov
Mon Aug 31 21:11:24 BST 2015
I'm attempting to merge an old CGI.pm-based code base into a
Dancer2-powered app, and I have some questions. I had been running the old
code using Plack::App::CGIBin to mount the .cgi files, but there is now
enough code shared between the two that I am ready to merge the two. The
shared code currently runs some preflight checks, and then parses the query
params to figure out the correct modules to load and subroutine to dispatch.
1) The old code is written in a "print as you go" form. My initial idea was
to capture the STDOUT, but unfortunately the code includes some hacks to
keep the browser connection open when running long processes (rather than
forking a child process and periodically checking on its process, using an
event loop, etc.). There's lots of code like this:
print "<p>Launching lengthy process...</p>";
my $data = do_something_that_takes_ages_here();
print "<p>Finished part one of lengthy process. Starting phase two!</p>";
I'd like to use Dancer2's streaming/async capabilities here but am not sure
how to send what is printed to STDOUT to the 'content' keyword. Can anyone
2) I'm converting the PSGI env into a CGI object using CGI::PSGI; apart
from HTTP headers, is there anything else I need to take care of?
Thank you for any help and hints!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the dancer-users