=head1 VERSION
0.0.4
=head1 LIMITATIONS
Currently the only supported mime-type is application/json.
=head1 SEE ALSO
L<Sleep::Handler|Sleep::Handler>, L<Sleep::Resource|Sleep::Resource>,
L<Sleep:
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;
ub encode {
my $self = shift;
my $as = shift;
if ($as eq 'application/json') {
return encode_json($self->data());
}
croak "Can't encode";
}
1;
__END__
=head1 NAME
equest->new($r, $db, @vars);
my $method = lc $r->method();
my $mime_type = 'application/json';
if ($method =~ m/^get|post|put|delete$/) {
if ($method eq 'get') {
my
package Sleep::Request;
use strict;
use warnings;
use JSON::XS;
sub new {
my $klass = shift;
my $request = shift;
my $db = shift;
my @vars = @_;
my $self = bless { re
rs}->[0];
}
sub decode {
my $self = shift;
my $data = shift;
$self->{data} = decode_json($data);
return;
}
sub data {
my $self = shift;
return $self->{data};
}
1;
__END__
DS
=over 4
=item id
Returns the first variable from C<vars>.
=item decode($data)
Parses the JSON data in C<$data> to a perl representation. Retrieve this value using C<data>.
=item data
Return