Added WebGUI::Requestion/Response

This commit is contained in:
Patrick Donelan 2010-04-06 19:35:06 -04:00
parent 2516ff12c1
commit 72017cf83f
5 changed files with 60 additions and 8 deletions

11
README Normal file
View file

@ -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.

View file

@ -1,5 +1,7 @@
package WebGUI::Session::Plack; package WebGUI::Session::Plack;
# This file is deprecated - keeping it here for reference until everything has been ported
use strict; use strict;
use warnings; use warnings;
use Carp; use Carp;

View file

@ -25,8 +25,8 @@ use WebGUI::Config;
use WebGUI::Pluggable; use WebGUI::Pluggable;
use WebGUI::Session; use WebGUI::Session;
use WebGUI::User; use WebGUI::User;
use WebGUI::Request;
use Moose; use Moose;
use Plack::Request;
has root => ( is => 'ro', isa => 'Str', default => '/data/WebGUI' ); has root => ( is => 'ro', isa => 'Str', default => '/data/WebGUI' );
has site => ( is => 'ro', isa => 'Str', default => 'dev.localhost.localdomain.conf' ); has site => ( is => 'ro', isa => 'Str', default => 'dev.localhost.localdomain.conf' );
@ -69,11 +69,11 @@ around BUILDARGS => sub {
}; };
sub BUILD { sub BUILD {
my $self = shift; my $self = shift;
# Instantiate the WebGUI::Config object # Instantiate the WebGUI::Config object
my $config = WebGUI::Config->new( $self->root, $self->site ); my $config = WebGUI::Config->new( $self->root, $self->site );
$self->config( $config ); $self->config($config);
} }
sub psgi_app { sub psgi_app {
@ -86,7 +86,7 @@ sub compile_psgi_app {
my $app = sub { my $app = sub {
my $env = shift; 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); my $response = $self->dispatch($request);
return $response; return $response;
}; };
@ -119,7 +119,7 @@ sub dispatch {
my $config = $self->config; my $config = $self->config;
# determine session id # determine session id
my $sessionId = $request->cookies->{$config->getCookieName}; my $sessionId = $request->cookies->{$config->getCookieName};
# Instantiate the session object # Instantiate the session object
my $session = $self->session( WebGUI::Session->open($self->root, $config, $request, $sessionId) ); my $session = $self->session( WebGUI::Session->open($self->root, $config, $request, $sessionId) );

29
lib/WebGUI/Request.pm Normal file
View file

@ -0,0 +1,29 @@
package WebGUI::Request;
=head2 DESCRIPTION
The WebGUI server response object. See L<Plack::Response>
=cut
use parent qw(Plack::Request);
use WebGUI::Response;
=head1 METHODS
=head2 new_response ()
Creates a new L<WebGUI::Response> object.
N.B. A L<WebGUI::Response> object is automatically created when L<WebGUI::Session>
is instantiated, so in most cases you will not need to call this method.
See L<WebGUI::Session/response>
=cut
sub new_response {
my $self = shift;
WebGUI::Response->new(@_);
}
1;

10
lib/WebGUI/Response.pm Normal file
View file

@ -0,0 +1,10 @@
package WebGUI::Response;
use parent qw(Plack::Response);
=head2 DESCRIPTION
The WebGUI server response object. See of L<Plack::Response>
=cut
1;