| Catalyst::Controller::CGIBin - Serve CGIs from root/cgi-bin |
Catalyst::Controller::CGIBin - Serve CGIs from root/cgi-bin
Version 0.016
In your controller:
package MyApp::Controller::Foo;
use parent qw/Catalyst::Controller::CGIBin/;
# example of a forward to /cgi-bin/hlagh/mtfnpy.cgi
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_dir cgi-bin
<CGI>
username_field username # used for REMOTE_USER env var
pass_env PERL5LIB
pass_env PATH
pass_env /^MYAPP_/
</CGI>
</Controller::Foo>
Dispatches to CGI files in root/cgi-bin for /cgi-bin/ paths.
Unlike the ModPerl::Registry manpage this module does _NOT_ stat and recompile the CGI for every invocation. This may be supported in the future if there's interest.
CGI paths are converted into action names using cgi_action.
Inherits from the Catalyst::Controller::WrapCGI manpage, see the documentation for that module for other configuration information.
The global URI path prefix for CGIs, defaults to cgi-bin.
Path from which to read CGI files. Can be relative to $MYAPP_HOME/root or
absolute. Defaults to $MYAPP_HOME/root/cgi-bin.
$self->cgi_action($cgi)
Takes a path to a CGI from root/cgi-bin such as foo/bar.cgi and returns
the action name it is registered as. See DESCRIPTION for a discussion on how
CGI actions are named.
A path such as root/cgi-bin/hlagh/bar.cgi will get the private path
foo/CGI_hlagh__bar_cgi, for controller Foo, with the /s converted to __
and prepended with CGI_, as well as all non-word characters converted to
_s. This is because Catalyst action names can't have non-word characters
in them.
This means that foo/bar.cgi and foo__bar.cgi for example will both map to
the action CGI_foo__bar_cgi so DON'T DO THAT.
$self->cgi_path($cgi)
Takes a path to a CGI from root/cgi-bin such as foo/bar.cgi and returns
the public path it should be registered under.
The default is to prefix with $cgi_root_path/, using the cgi_root_path
config setting, above.
$self->is_perl_cgi($path)
Tries to figure out whether the CGI is Perl or not.
If it's Perl, it will be inlined into a sub instead of being forked off, see wrap_perl_cgi.
$self->wrap_perl_cgi($path, $action_name)
Takes the path to a Perl CGI and returns a coderef suitable for passing to cgi_to_response (from the Catalyst::Controller::WrapCGI manpage.)
$action_name is the generated name for the action representing the CGI file
from cgi_action.
This is similar to how the ModPerl::Registry manpage works, but will only work for well-written CGIs. Otherwise, you may have to override this method to do something more involved (see the ModPerl::PerlRun manpage.)
Scripts with __DATA__ sections now work too, as well as scripts that call
exit().
$self->wrap_nonperl_cgi($path, $action_name)
Takes the path to a non-Perl CGI and returns a coderef for executing it.
$action_name is the generated name for the action representing the CGI file.
By default returns:
sub { system $path }
the Catalyst::Controller::WrapCGI manpage, the CatalystX::GlobalContext manpage, the Catalyst::Controller manpage, CGI, Catalyst
Rafael Kitover, <rkitover at cpan.org>
Hans Dieter Pearcey, <hdp at cpan.org>
Please report any bugs or feature requests to bug-catalyst-controller-wrapcgi at
rt.cpan.org, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
More information at:
Copyright (c) 2008 Rafael Kitover
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Catalyst::Controller::CGIBin - Serve CGIs from root/cgi-bin |