Refactored Request/Response into WebGUI::Session::

This commit is contained in:
Patrick Donelan 2010-04-08 21:30:55 -04:00
parent 1ad2f0cfd7
commit b7e7d5b936
5 changed files with 117 additions and 90 deletions

View file

@ -0,0 +1,36 @@
package WebGUI::Session::Response;
use strict;
use parent qw(Plack::Response);
use Plack::Util::Accessor qw(session streaming writer streamer);
=head1 SYNOPSIS
my $session = WebGUI::Session->open(...);
my $response = $session->response;
=head1 DESCRIPTION
WebGUI's PSGI response utility class. Sub-classes L<Plack::Response>.
An instance of this object is created automatically when the L<WebGUI::Session>
is created.
=cut
sub stream {
my $self = shift;
$self->streamer(shift);
$self->streaming(1);
}
sub stream_write {
my $self = shift;
if (!$self->streaming) {
Carp::carp("stream_write can only be called inside streaming response");
return;
}
$self->writer->write(@_);
}
1;