Apache2::REST::Writer::yaml - Apache2::REST::Response Writer for yaml


Apache2-REST documentation Contained in the Apache2-REST distribution.

Index


Code Index:

NAME

Top

Apache2::REST::Writer::yaml - Apache2::REST::Response Writer for yaml

new

mimeType

Getter

asBytes

Returns the response as yaml UTF8 bytes for output.


Apache2-REST documentation Contained in the Apache2-REST distribution.
package Apache2::REST::Writer::yaml ;
use strict ;

use YAML;

use Data::Dumper ;

sub new{
    my ( $class ) = @_;
    return bless {} , $class;
}

sub mimeType{
    return 'text/yaml';
}

sub asBytes{
    my ($self,  $resp ) = @_ ;
    ## Shallow unblessed copy
    my %resp = %$resp ;
    my $yaml = Dump(\%resp) ;
    ## yaml is a perl string, not bytes.
    return Encode::encode_utf8($yaml) ;
}

1;