| Sleep documentation | Contained in the Sleep distribution. |
Sleep::Response - A Sleep response
Has two optional parameters: data and location.
Returns the data of this response.
Returns the location that was specified for this response. This value will be
used by Sleep::Handler to set the Location HTTP header.
If you find a bug, please let the author know.
Copyright (c) 2008 Peter Stuifzand. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Peter Stuifzand <peter@stuifzand.eu>
| Sleep documentation | Contained in the Sleep distribution. |
package Sleep::Response; use strict; use warnings; use Carp; use JSON::XS; sub new { my $klass = shift; my $args = shift || {}; my $self = bless { %$args }, $klass; return $self; } sub data { my $self = shift; return $self->{data}; } sub location { my $self = shift; return $self->{location}; } sub encode { my $self = shift; my $as = shift; if ($as eq 'application/json') { return encode_json($self->data()); } croak "Can't encode"; } 1; __END__