X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FResponse.pm;h=cb280dd2b50290d3ece519ba54d65dc3b0d60ad7;hp=877f8c967daea14e14ea0fe987a6155f63bf9a23;hb=ac5c933bdd463558e8d621507a53a7b247a9093e;hpb=46372e65373a893323ebcb5cb97427d579c7e85a diff --git a/lib/Catalyst/Response.pm b/lib/Catalyst/Response.pm index 877f8c9..cb280dd 100644 --- a/lib/Catalyst/Response.pm +++ b/lib/Catalyst/Response.pm @@ -1,16 +1,24 @@ package Catalyst::Response; -use strict; -use base 'Class::Accessor::Fast'; +use Moose; -__PACKAGE__->mk_accessors(qw/cookies body headers location status/); +has cookies => (is => 'rw'); +has body => (is => 'rw'); +has location => (is => 'rw'); +has status => (is => 'rw'); +has headers => ( + is => 'rw', + handles => [qw(content_encoding content_length content_type header)], +); -*output = \&body; +has _context => ( + is => 'rw', + weak_ref => 1, +); -sub content_encoding { shift->headers->content_encoding(@_) } -sub content_length { shift->headers->content_length(@_) } -sub content_type { shift->headers->content_type(@_) } -sub header { shift->headers->header(@_) } +sub output { shift->body(@_) } + +no Moose; =head1 NAME @@ -127,6 +135,10 @@ sub redirect { return $self->location; } +=head2 $res->location + +Sets or returns the HTTP 'Location'. + =head2 $res->status Sets or returns the HTTP status. @@ -139,7 +151,11 @@ Writes $data to the output stream. =cut -sub write { shift->{_context}->write(@_); } +sub write { shift->_context->write(@_); } + +=head2 meta + +Provided by Moose =head1 AUTHORS @@ -154,4 +170,6 @@ it under the same terms as Perl itself. =cut +__PACKAGE__->meta->make_immutable; + 1;