Apache2-REST

 view release on metacpan or  search on metacpan

lib/Apache2/REST/Handler.pm  view on Meta::CPAN

Called like this by the framework:

$this->buildNext($frag , $req ) ;

Overriding use cases:

- Build a dynamic handler.
  For instance if the fragment is an item ID, you might want to build an item handler with this particular item. See L<Apache2::REST::Handler::test> for an example.

- Rerouting outside of the handler classes space.
  If you want to escape the default class resolution mecanism.


=cut

sub buildNext{
    my ( $self , $frag , $req ) = @_ ;
    ## default implementation
    
    my $newC = $self->class().'::'.$frag ;
    eval "require $newC;";

lib/Apache2/REST/Writer/xml_stream.pm  view on Meta::CPAN

}

=head2 getPreambleBytes

Returns the response as xml UTF8 bytes for output.

=cut

sub getPreambleBytes{
    my ($self,  $resp ) = @_ ;
    ## To check: escape_value exists in XML::Simple object.
    my $xmlString = q|<?xml version="1.0" encoding="UTF-8" ?>
<response type="streamed" message="|.$self->{xml_simple}->escape_value($resp->message()).q|" status="|.$self->{xml_simple}->escape_value($resp->status()).q|">
|;
    
    $xmlString .=  XMLout($resp->data() , RootName => 'data' ) ;
    # xmlString is a string, not bytes
    # return bytes.
    return Encode::encode_utf8($xmlString) ;
}

sub getPostambleBytes{
    my ($self, $resp) = @_;



( run in 0.406 second using v1.01-cache-2.11-cpan-c21f80fb71c )