I am using
CGI::Fast to leverage the speed and scalability of FastCGI, and I also CGI.pm's query string parsing. I do not use CGI.pm's deprecated HTML writing functions.
Stopping the use of CGI.pm is strongly advised in the community, but in my use case, should I also be thinking of migrating away? And if so, how do I
1) still leverage FastCGI
2) grab query params
...without adopting a framework like Dancer or Mojolicious?
The code I am looking at replacing is just:
I am open to using something like
CGI::PSGI in conjunction with
Plack::Request, but I couldn't see how to finesse the FastCGI functionality as
CGI::PSGI both want to subclass
CGI for the creation of the object. And I'd still have CGI.pm in the mix to enable
CGI::Fast. Plack seems like a lot to learn to replace what is now a few lines of code.
This neatly illustrates one reason why PSGI is an improvement on CGI (and its related technologies like FastCGI). In CGI-style programs, the code is tightly coupled with the deployment method and when you change the deployment method, you usually need to make quite large changes to the code. With PSGI-style programs, the code is the same no matter how you deploy it.
You haven't shown us any of your code, but you talk about "a few lines of code". So here's the approach I'd take.
- Rip all FastCGI-specific code out of your program - leaving a pure CGI-style program.
- You then have a choice. You could use the techniques I describe in Easy PSGI to convert your program to a pure PSGI program. Or, if that's going to be too much work, use CGI::PSGI to run your CGI program in a PSGI environment.
- You now have a PSGI program that you can use in pretty much any web server environment. You can serve it as a CGI program. You can use Plack::Handler::FCGI to run it under FCGI. Or you can deploy it as a standalone service behind a web proxy (that last option is the one I'd choose).
But any choice you make at step 3 isn't irrevocable. The same code will work in all deployment environments. And, therefore, moving between them is usually pretty simple.
p.s. CGI.pm isn't exactly deprecated. It has been removed from the standard Perl distribution but that's because its use is discouraged.