API-Handle
view release on metacpan or search on metacpan
lib/API/Handle/OpenX.pm view on Meta::CPAN
# Add request wrapper.
$self->ua->add_handler(
request_prepare => sub {
my ( $req, $ua, $h ) = @_;
# Create SOAP envelope.
if ( my $data = $req->content ) {
my $json = $self->_encode( type => 'json', data => $data );
$req->content( $json );
$req->headers->header( 'Content-Type' => 'application/json; charset=utf-8' );
# Uncomment this to view generated JSON content.
# $self->debug( $json );
}
}
, m_scheme => $scheme
, m_host => $host
, m_path_match => qr/^\Q$path\E/
);
# Add response wrapper.
$self->ua->add_handler(
response_done => sub {
my ( $res, $ua, $h ) = @_;
if ( my $data = $res->content ) {
$data = $self->_decode( type => 'json', data => $data );
$res->content( $data );
}
}
, m_scheme => $scheme
, m_host => $host
, m_path_match => qr/^\Q$path\E/
, m_code => 200
);
return $prev;
};
__PACKAGE__->meta->make_immutable;
1;
__END__
=pod
=head1 NAME
API::Handle::OpenX
=head1 VERSION
version 0.02
=head1 AUTHOR
Nour Sharabash <amirite@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Nour Sharabash.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
( run in 0.942 second using v1.01-cache-2.11-cpan-bbcb1afb8fc )