X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FController%2FCGIBin.pm;h=b31b0da99e87c22f34f75523355fc5cf36446a8b;hb=9cd473644d9076cfc98c97e72731d5492e9ff7e2;hp=773d52e48f061cc376a8d7a7e61cdbffddf6195f;hpb=fbaba9ddb929f1437ddaec1f24019f38beb99c75;p=catagits%2FCatalyst-Controller-WrapCGI.git diff --git a/lib/Catalyst/Controller/CGIBin.pm b/lib/Catalyst/Controller/CGIBin.pm index 773d52e..b31b0da 100644 --- a/lib/Catalyst/Controller/CGIBin.pm +++ b/lib/Catalyst/Controller/CGIBin.pm @@ -1,10 +1,10 @@ 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 (); @@ -16,8 +16,6 @@ use IO::File (); use Carp; use namespace::clean -except => 'meta'; -use parent 'Catalyst::Controller::WrapCGI'; - =head1 NAME Catalyst::Controller::CGIBin - Serve CGIs from root/cgi-bin @@ -39,7 +37,7 @@ In your controller: 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')); } @@ -47,6 +45,7 @@ In your controller: In your .conf: + cgi_root_path cgi-bin username_field username # used for REMOTE_USER env var pass_env PERL5LIB @@ -69,6 +68,8 @@ module for configuration information. =cut +has cgi_root_path => (is => 'ro', isa => 'Str', default => 'cgi-bin'); + sub register_actions { my ($self, $app) = @_; @@ -160,13 +161,17 @@ sub cgi_action { Takes a path to a CGI from C such as C and returns the public path it should be registered under. -The default is C. +The default is to prefix with the C config setting, or if not set +uses C. =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)