[Catalyst-commits] r9845 - in trunk/Catalyst-Controller-WrapCGI: .
lib/Catalyst/Controller t t/lib/TestCGIBin/Controller
hdp at dev.catalyst.perl.org
hdp at dev.catalyst.perl.org
Sun Apr 26 00:36:57 GMT 2009
Author: hdp
Date: 2009-04-26 01:36:57 +0100 (Sun, 26 Apr 2009)
New Revision: 9845
Modified:
trunk/Catalyst-Controller-WrapCGI/Changes
trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/CGIBin.pm
trunk/Catalyst-Controller-WrapCGI/t/cgibin.t
trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBin/Controller/CGIHandler.pm
Log:
allow overriding of public cgi-bin paths
Modified: trunk/Catalyst-Controller-WrapCGI/Changes
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/Changes 2009-04-26 00:05:01 UTC (rev 9844)
+++ trunk/Catalyst-Controller-WrapCGI/Changes 2009-04-26 00:36:57 UTC (rev 9845)
@@ -25,3 +25,6 @@
0.0028 2009-04-24 04:40:39
Add support for __DATA__ sections in cgis for C::CGIBin
+
+0.0029
+ Allow more control over public paths to CGIBin actions.
Modified: trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/CGIBin.pm
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/CGIBin.pm 2009-04-26 00:05:01 UTC (rev 9844)
+++ trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/CGIBin.pm 2009-04-26 00:36:57 UTC (rev 9845)
@@ -91,8 +91,9 @@
my $path = join '/' => splitdir($cgi_path);
my $action_name = $self->cgi_action($path);
+ my $public_path = $self->cgi_path($path);
my $reverse = $namespace ? "$namespace/$action_name" : $action_name;
- my $attrs = { Path => [ "cgi-bin/$path" ], Args => [ 0 ] };
+ my $attrs = { Path => [ $public_path ], Args => [ 0 ] };
my ($cgi, $type);
@@ -134,7 +135,7 @@
=head1 METHODS
-=head2 $self->cgi_action($cgi_path)
+=head2 $self->cgi_action($cgi)
Takes a path to a CGI from C<root/cgi-bin> such as C<foo/bar.cgi> and returns
the action name it is registered as. See L</DESCRIPTION> for a discussion on how
@@ -151,6 +152,20 @@
$action_name
}
+=head2 $self->cgi_path($cgi)
+
+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>.
+
+=cut
+
+sub cgi_path {
+ my ($self, $cgi) = @_;
+ return "cgi-bin/$cgi";
+}
+
=head2 $self->is_perl_cgi($path)
Tries to figure out whether the CGI is Perl or not.
Modified: trunk/Catalyst-Controller-WrapCGI/t/cgibin.t
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/t/cgibin.t 2009-04-26 00:05:01 UTC (rev 9844)
+++ trunk/Catalyst-Controller-WrapCGI/t/cgibin.t 2009-04-26 00:36:57 UTC (rev 9845)
@@ -14,7 +14,7 @@
# this should be ignored
$ENV{MOD_PERL} = "mod_perl/2.0";
-my $response = request POST '/cgi-bin/path/test.pl', [
+my $response = request POST '/my-bin/path/test.pl', [
foo => 'bar',
bar => 'baz'
];
@@ -41,5 +41,5 @@
skip "Can't run shell scripts on non-*nix", 1
if $^O eq 'MSWin32' || $^O eq 'VMS';
- is(get('/cgi-bin/test.sh'), "Hello!\n", 'Non-Perl CGI File');
+ is(get('/my-bin/test.sh'), "Hello!\n", 'Non-Perl CGI File');
}
Modified: trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBin/Controller/CGIHandler.pm
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBin/Controller/CGIHandler.pm 2009-04-26 00:05:01 UTC (rev 9844)
+++ trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBin/Controller/CGIHandler.pm 2009-04-26 00:36:57 UTC (rev 9845)
@@ -2,6 +2,11 @@
use parent 'Catalyst::Controller::CGIBin';
+sub cgi_path {
+ my ($self, $cgi) = @_;
+ return "my-bin/$cgi";
+}
+
# try out a forward
sub dongs : Local Args(0) {
my ($self, $c) = @_;
More information about the Catalyst-commits
mailing list