From 72017cf83f2b76ff337e96b8ddb972806cf5650b Mon Sep 17 00:00:00 2001 From: Patrick Donelan Date: Tue, 6 Apr 2010 19:35:06 -0400 Subject: [PATCH] Added WebGUI::Requestion/Response --- README | 11 +++++++ .../Plack.pm => WebGUI-Session-Plack.pm | 2 ++ lib/WebGUI.pm | 16 +++++----- lib/WebGUI/Request.pm | 29 +++++++++++++++++++ lib/WebGUI/Response.pm | 10 +++++++ 5 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 README rename lib/WebGUI/Session/Plack.pm => WebGUI-Session-Plack.pm (97%) create mode 100644 lib/WebGUI/Request.pm create mode 100644 lib/WebGUI/Response.pm diff --git a/README b/README new file mode 100644 index 000000000..f37e9ba14 --- /dev/null +++ b/README @@ -0,0 +1,11 @@ +This is the PSGI branch of WebGUI8 + +Currently, the best performance is achieved via: + + plackup eg/basic.psgi -E none -s Starman --workers 10 + +You can benchmark your server via: + + ab -t 3 -c 10 -k http://dev.localhost.localdomain:5000/ | grep Req + +I'm currently getting 20 requests/second, whereas I'm getting 30/second on the non-PSGI WebGUI8 branch. \ No newline at end of file diff --git a/lib/WebGUI/Session/Plack.pm b/WebGUI-Session-Plack.pm similarity index 97% rename from lib/WebGUI/Session/Plack.pm rename to WebGUI-Session-Plack.pm index c60f04aa8..411f6775c 100644 --- a/lib/WebGUI/Session/Plack.pm +++ b/WebGUI-Session-Plack.pm @@ -1,5 +1,7 @@ package WebGUI::Session::Plack; +# This file is deprecated - keeping it here for reference until everything has been ported + use strict; use warnings; use Carp; diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index b9cf47853..96e5dd230 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -25,8 +25,8 @@ use WebGUI::Config; use WebGUI::Pluggable; use WebGUI::Session; use WebGUI::User; +use WebGUI::Request; use Moose; -use Plack::Request; has root => ( is => 'ro', isa => 'Str', default => '/data/WebGUI' ); has site => ( is => 'ro', isa => 'Str', default => 'dev.localhost.localdomain.conf' ); @@ -69,11 +69,11 @@ around BUILDARGS => sub { }; sub BUILD { - my $self = shift; - - # Instantiate the WebGUI::Config object - my $config = WebGUI::Config->new( $self->root, $self->site ); - $self->config( $config ); + my $self = shift; + + # Instantiate the WebGUI::Config object + my $config = WebGUI::Config->new( $self->root, $self->site ); + $self->config($config); } sub psgi_app { @@ -86,7 +86,7 @@ sub compile_psgi_app { my $app = sub { my $env = shift; - my $request = Plack::Request->new($env); # This could also be WebGUI::Request + my $request = WebGUI::Request->new($env); my $response = $self->dispatch($request); return $response; }; @@ -119,7 +119,7 @@ sub dispatch { my $config = $self->config; # determine session id - my $sessionId = $request->cookies->{$config->getCookieName}; + my $sessionId = $request->cookies->{$config->getCookieName}; # Instantiate the session object my $session = $self->session( WebGUI::Session->open($self->root, $config, $request, $sessionId) ); diff --git a/lib/WebGUI/Request.pm b/lib/WebGUI/Request.pm new file mode 100644 index 000000000..873462102 --- /dev/null +++ b/lib/WebGUI/Request.pm @@ -0,0 +1,29 @@ +package WebGUI::Request; + +=head2 DESCRIPTION + +The WebGUI server response object. See L + +=cut + +use parent qw(Plack::Request); +use WebGUI::Response; + +=head1 METHODS + +=head2 new_response () + +Creates a new L object. + +N.B. A L object is automatically created when L +is instantiated, so in most cases you will not need to call this method. +See L + +=cut + +sub new_response { + my $self = shift; + WebGUI::Response->new(@_); +} + +1; \ No newline at end of file diff --git a/lib/WebGUI/Response.pm b/lib/WebGUI/Response.pm new file mode 100644 index 000000000..e57bd1303 --- /dev/null +++ b/lib/WebGUI/Response.pm @@ -0,0 +1,10 @@ +package WebGUI::Response; +use parent qw(Plack::Response); + +=head2 DESCRIPTION + +The WebGUI server response object. See of L + +=cut + +1; \ No newline at end of file