Dancer::Plugin::FakeCGI - run CGI methods or Perl-files under Dancer
Supports to run CGI perl files on CGI methods under Dancer.
plugins: FakeCGI: cgi-dir: 'cgi-dir' cgi-bin: '/cgi-bin' cgi-package: 'lib/CGI' cgi-class: ourCGI stdout-type: "file" temp-dir: "tmp"
after
every CGI files are loaded(served) 20-50% slowest then under Mod_PERL(Registry.pm). This emulation get about 15-20ms more than uner Apache. Next difference is capture in memory and to file. In memory is 10-20% faster. One problem finded and there is Cwd::cwd() function which is slowest than getcwd() and take 65ms. CGI::Compile() is similar as Mod_PERL::PerlRun(). Everytime it run eval() on given loaded code. If we want to use behavior as Apache::Registry(), than should on first time evaled of given code to memory as package with function and other every call run this method to omited evaled code into memory.
_run_code()
Method which return url for given $name. If set @other, than this will be append to given URL with separattor /
$name
@other
Method for runned specified CGI method-function and return values of runned function.
Method for runned specified Perl CGI file and returned exit value
Load packages into memory or Compiled files into memory. @args is array of this HASHREF options:
Tries to figure out whether the CGI is Perl code or not.
Return 1 if its Perl code otherwise is 0.
Automatically serve CGI files from cgi-dir directory
plugins: FakeCGI: cgi-bin_file_pattern: *.cgi
Setting cgi-bin_file_pattern can be defined as array is pattern of file or files, which will be readed and try to compiled and setted to run as CGI.
Given method should return true or false. If given code no return true, than serve given CGI files in standart way.
This is parametter for given called code:
plugins: FakeCGI: cgi-bin_file_pattern: "*.pl"
In yours Dancer package only put fake_cgi_bin(); and this script try to load every *.pl files in cgi-bin directory under Dancer directory.
fake_cgi_bin();
sub test_file { my ($cgi_bin, $cgi, $url, $is_perl) = @_; return 1 if ($cgi =~ /^\./); # skip serving this file return 1 if ($cgi =~ /test.pl/); # skip serving this file if ($cgi eq "index.pl") { # own serving for given file any $url => sub { redirect "/index.sh"; }; return 1; } return 0; # default server } fake_cgi_bin(\&test_file, ["*.pl", "*.sh"], 1);
Return captured strings from CGI, which will be printed to STDOUT.
If $ret_ref than given string will be returned as reference to SCALAR. This option can make better performance.
This method every time return actuall settings form capture method.
If argument $capture_start is defined, can be possible START or STOP capturing with this options:
This plugin uses Dancer's hooks support to allow you to register code that should execute at given times.
hook 'fake_cgi_before' => sub { my ($env,$capture) = @_; }; hook 'fake_cgi_after' => sub { my ($capture) = @_; };
Igor Bujna, <igor.bujna@post.cz>
<igor.bujna@post.cz>
For every developers of this packages, when made good ideas for this code :
Catalyst::Controller::CGIBin, HTTP::Request::AsCGI, CGI::PSGI, CGI::Emulate::PSGI
Catalyst::Controller::CGIBin
HTTP::Request::AsCGI
CGI::PSGI
CGI::Emulate::PSGI
Copyright 2010-2013 Igor Bujna.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
Dancer
IO::Scalar
CGI::Compile
Test::TinyMocker
HTTP::Message
To install Dancer::Plugin::FakeCGI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer::Plugin::FakeCGI
CPAN shell
perl -MCPAN -e shell install Dancer::Plugin::FakeCGI
For more information on module installation, please visit the detailed CPAN module installation guide.