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"
cgi-dir
cgi-bin
cgi-package
fake_cgi_method
cgi-class
stdout-type
file
temp-dir
memory
STDOUT|STDERR
string
io_fh
filename
header_len
std_fh
capture_stderr
d=item timeout - in seconds which can timeouted given eval via alaram() function. 0|undefined - disabled it
timeout
ret_error
Method which return url for given $name. If set @other, than this will be append to given URL
$name
@other
Method for runned specified CGI method-function and return values of runned function.
$package
$method
$params
_run_code()
@args
Method for runned specified Perl CGI file and returned exit value
$file
$test_is_perl
Load packages into memory or Compiled files into memory
Tries to figure out whether the CGI is Perl code or not.
Return 1 if its Perl code otherwise is 0.
$compile
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.
cgi-bin_file_pattern
$code
$paterns
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();
*.pl
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
This method every time return actuall settings form capture method.
If argument $capture_start is defined, can be possible START or STOP capturing.
$capture_start
true|1
false|0
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.