use strict;
use warnings;
-use Class::C3;
-use URI::Escape;
+use MRO::Compat;
+use mro 'c3';
use File::Slurp 'slurp';
use File::Find::Rule ();
use Catalyst::Exception ();
use Symbol 'gensym';
use List::MoreUtils 'any';
use IO::File ();
+use Carp;
+use namespace::clean -except => 'meta';
use parent 'Catalyst::Controller::WrapCGI';
=head1 VERSION
-Version 0.003
+Version 0.006
=cut
-our $VERSION = '0.003';
+our $VERSION = '0.006';
=head1 SYNOPSIS
}
$self->next::method($app, @_);
+
+# Tell Static::Simple to ignore the cgi-bin dir.
+ if (!any{ $_ eq 'cgi-bin' } @{ $app->config->{static}{ignore_dirs}||[] }) {
+ push @{ $app->config->{static}{ignore_dirs} }, 'cgi-bin';
+ }
}
=head1 METHODS
sub wrap_perl_cgi {
my ($self, $cgi, $action_name) = @_;
- do {
+ my $code = slurp $cgi;
+
+ $code =~ s/^__DATA__\r?\n(.*)//ms;
+ my $data = $1;
+
+ my $coderef = do {
no warnings;
-# CGIs import stuff, so putting them into this package breaks Cat 5.8
eval '
package Catalyst::Controller::CGIBin::_CGIs_::'.$action_name.';
- sub {' . slurp($cgi) . '}'
- }
+ sub {'
+ . 'local *DATA;'
+ . q{open DATA, '<', \$data;}
+ . $code
+ . '}';
+ };
+
+ croak __PACKAGE__ . ": Could not compile $cgi to coderef: $@" if $@;
+
+ $coderef
}
=head2 $self->wrap_nonperl_cgi($path, $action_name)