Revision history for Catalyst-Controller-WrapCGI
-0.001 2008-06-28 15:28:46
- First complete dist.
+0.0029 2009-04-26 20:54:28
+ - Allow more control over public paths to CGIBin actions. (confound)
+ - Override exit() in CGIBin-wrapped Perl cgis to avoid terminating the
+ Catalyst process. (confound)
+ - Set (temporarily) $0 to the filename of the Perl cgi being executed.
+ (confound)
+ - cgi_root_path accessor, convert to Moose (caelum)
+ - slight rewrite of docs and a test for __DATA__ (caelum)
-0.002 2008-07-02 23:02:20
- First release.
+0.0028 2009-04-24 04:40:39
+ - Add support for __DATA__ sections in cgis for C::CGIBin (caelum)
-0.0022 2008-07-04 02:52:52
- Fixed test shell script portability and missing dep on Class::C3
+0.0027 2009-04-03 14:55:34
+ - Add 'kill_env' and default to killing 'MOD_PERL' from environment.
+ (confound)
-0.0024 2008-11-19 16:00:54
- Fixed for Catalyst 5.8
+0.0026 2009-02-02
+ - Stop storing generated files in SVN and add svn:ignore.
+ - Remove taint from tests as this breaks in a local::lib environment
+ as PERL5LIB is stripped.
0.0025 2009-01-09 14:59:20
- Tell Static::Simple to ignore root/cgi-bin for C::C::CGIBin
+ - Tell Static::Simple to ignore root/cgi-bin for C::C::CGIBin (caelum)
-0.0026 2009-02-02
- Stop storing generated files in SVN and add svn:ignore.
- Remove taint from tests as this breaks in a local::lib environment
- as PERL5LIB is stripped.
-
-0.0027 2009-04-03 14:55:34
- Add 'kill_env' and default to killing 'MOD_PERL' from environment.
+0.0024 2008-11-19 16:00:54
+ - Fixed for Catalyst 5.8 (caelum)
-0.0028 2009-04-24 04:40:39
- Add support for __DATA__ sections in cgis for C::CGIBin
+0.002 2008-07-02 23:02:20
+ - First release.
-0.0029
- Allow more control over public paths to CGIBin actions.
- Override exit() in CGIBin-wrapped Perl cgis to avoid terminating the
- Catalyst process.
- Set (temporarily) $0 to the filename of the Perl cgi being executed.
+0.001 2008-06-28 15:28:46
+ - First complete dist.
package Catalyst::Controller::CGIBin;
-use strict;
-use warnings;
-
-use MRO::Compat;
+use Moose;
use mro 'c3';
+
+extends 'Catalyst::Controller::WrapCGI';
+
use File::Slurp 'slurp';
use File::Find::Rule ();
use Catalyst::Exception ();
use Carp;
use namespace::clean -except => 'meta';
-use parent 'Catalyst::Controller::WrapCGI';
-
=head1 NAME
Catalyst::Controller::CGIBin - Serve CGIs from root/cgi-bin
use parent qw/Catalyst::Controller::CGIBin/;
# example of a forward to /cgi-bin/hlagh/mtfnpy.cgi
- sub dongs : Local Args(0) {
+ sub serve_cgi : Local Args(0) {
my ($self, $c) = @_;
$c->forward($self->cgi_action('hlagh/mtfnpy.cgi'));
}
In your .conf:
<Controller::Foo>
+ cgi_root_path cgi-bin
<CGI>
username_field username # used for REMOTE_USER env var
pass_env PERL5LIB
=cut
+has cgi_root_path => (is => 'ro', isa => 'Str', default => 'cgi-bin');
+
sub register_actions {
my ($self, $app) = @_;
Takes a path to a CGI from C<root/cgi-bin> such as C<foo/bar.cgi> and returns
the public path it should be registered under.
-The default is C<cgi-bin/$cgi>.
+The default is to prefix with the C<cgi_root_path> config setting, or if not set
+uses C<cgi-bin/$cgi>.
=cut
sub cgi_path {
my ($self, $cgi) = @_;
- return "cgi-bin/$cgi";
+
+ my $root = $self->cgi_root_path;
+ $root =~ s{/*$}{};
+ return "$root/$cgi";
}
=head2 $self->is_perl_cgi($path)
--- /dev/null
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin '$Bin';
+use lib "$Bin/lib";
+
+use Test::More tests => 1;
+
+use Catalyst::Test 'TestCGIBinRoot';
+use HTTP::Request::Common;
+
+# test default root of "cgi-bin"
+
+my $response = request POST '/cgi-bin/path/test.pl', [
+ foo => 'bar',
+ bar => 'baz'
+];
+
+is($response->content, 'foo:bar bar:baz', 'POST to Perl CGI File');