Apache2::REST::Writer::xml


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

Index


Code Index:

NAME

Top

Apache2::REST::Writer::xml - Apache2::REST::Response Writer for xml

new

mimeType

Getter

asBytes

Returns the response as xml UTF8 bytes for output.


Apache2-REST documentation Contained in the Apache2-REST distribution.
package Apache2::REST::Writer::xml ;
use strict ;
use XML::Simple ;

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


sub mimeType{
    return 'text/xml' ;
}

sub asBytes{
    my ($self,  $resp ) = @_ ;
    my $xmlString =  XMLout($resp , RootName => 'response' ) ;
    # xmlString is a string, not bytes
    # return bytes.
    return Encode::encode_utf8($xmlString) ;
}

1;