From 784e0bd73c2a2d91626175f0ce7100d5d5ac959b Mon Sep 17 00:00:00 2001 From: Patrick Donelan Date: Sun, 11 Oct 2009 01:07:08 +1100 Subject: [PATCH] Added Apache CGI/FCGI/mod_perl examples --- apache.conf | 21 +++++++++++++++++++++ etc/dev.localhost.localdomain.cgi | 5 +++++ etc/dev.localhost.localdomain.fcgi | 5 +++++ etc/dev.localhost.localdomain.psgi | 3 ++- lib/WebGUI/Session/Plack.pm | 7 ++++++- 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 apache.conf create mode 100755 etc/dev.localhost.localdomain.cgi create mode 100755 etc/dev.localhost.localdomain.fcgi diff --git a/apache.conf b/apache.conf new file mode 100644 index 000000000..7be1edbfe --- /dev/null +++ b/apache.conf @@ -0,0 +1,21 @@ + + PerlOptions +Parent + PerlSwitches -I/data/WebGUI/lib + + # CGI + #AddHandler cgi-script cgi + #ScriptAlias / /data/WebGUI/etc/dev.localhost.localdomain.cgi/ + # + # Options +ExecCGI + # + + # Apache2 + #SetHandler perl-script + #PerlHandler Plack::Server::Apache2 + #PerlSetVar psgi_app /data/WebGUI/etc/dev.localhost.localdomain.psgi + + # FastCGI + FastCgiServer /data/WebGUI/etc/dev.localhost.localdomain.fcgi + ScriptAlias / /data/WebGUI/etc/dev.localhost.localdomain.fcgi/ + + diff --git a/etc/dev.localhost.localdomain.cgi b/etc/dev.localhost.localdomain.cgi new file mode 100755 index 000000000..71eee8fab --- /dev/null +++ b/etc/dev.localhost.localdomain.cgi @@ -0,0 +1,5 @@ +#!/usr/bin/perl +use Plack::Server::CGI; + +my $app = Plack::Util::load_psgi("/data/WebGUI/etc/dev.localhost.localdomain.psgi"); +Plack::Server::CGI->new->run($app); \ No newline at end of file diff --git a/etc/dev.localhost.localdomain.fcgi b/etc/dev.localhost.localdomain.fcgi new file mode 100755 index 000000000..431274292 --- /dev/null +++ b/etc/dev.localhost.localdomain.fcgi @@ -0,0 +1,5 @@ +#!/usr/bin/perl +use Plack::Server::FCGI; + +my $app = Plack::Util::load_psgi("/data/WebGUI/etc/dev.localhost.localdomain.psgi"); +Plack::Server::FCGI->new->run($app); diff --git a/etc/dev.localhost.localdomain.psgi b/etc/dev.localhost.localdomain.psgi index 6ed510b33..b40d87272 100644 --- a/etc/dev.localhost.localdomain.psgi +++ b/etc/dev.localhost.localdomain.psgi @@ -6,7 +6,8 @@ BEGIN { our $WEBGUI_CONFIG = 'dev.localhost.localdomain'; our $DOCUMENT_ROOT = '/data/domains/dev.localhost.localdomain/public'; } -use local::lib $WEBGUI_ROOT; +use lib "$WEBGUI_ROOT/lib"; +#use local::lib $WEBGUI_ROOT; use WebGUI; use Plack::Builder; diff --git a/lib/WebGUI/Session/Plack.pm b/lib/WebGUI/Session/Plack.pm index a12dd30db..bf4672193 100644 --- a/lib/WebGUI/Session/Plack.pm +++ b/lib/WebGUI/Session/Plack.pm @@ -47,12 +47,17 @@ sub headers_out { shift->{headers_out} } sub protocol { shift->{request}->protocol(@_) } sub status { shift->{response}->status(@_) } sub sendfile { $_[0]->{sendfile} = $_[1] } -sub content_type { shift->{response}->content_type(@_) } sub server { shift->{server} } sub method { shift->{request}->method } sub upload { shift->{request}->upload(@_) } sub status_line { } sub auth_type { } # should we support this? +sub handler { 'perl-script' } # or not..? + +sub content_type { + my ($self, $ct) = @_; + $self->{headers_out}->set( 'Content-Type' => $ct ); +} # These two cookie subs are called from our wG Plack-specific code sub get_request_cookies {