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)