Sleep::Response - A Sleep response


Sleep documentation Contained in the Sleep distribution.

Index


Code Index:

NAME

Top

Sleep::Response - A Sleep response

DESCRIPTION

Top

CLASS METHODS

Top

CLASS->new($hash_ref)

Has two optional parameters: data and location.

METHODS

Top

data

Returns the data of this response.

location()

Returns the location that was specified for this response. This value will be used by Sleep::Handler to set the Location HTTP header.

encode($mime_type)

BUGS

Top

If you find a bug, please let the author know.

COPYRIGHT

Top

AUTHOR

Top

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__