App-Presto
view release on metacpan or search on metacpan
lib/App/Presto/Client.pm view on Meta::CPAN
sub PUT {
my $self = shift;
my $uri = $self->_make_uri(shift);
$self->_rest_client->PUT( $uri, shift );
}
sub _make_uri {
my $self = shift;
my $local_uri = shift;
my @args = @_;
my $config = $self->config;
my $endpoint;
$local_uri = '/' if ! defined $local_uri;
$local_uri = URI->new($local_uri);
if ( $local_uri->scheme ) {
$endpoint = $local_uri;
} else {
my $local_path = $local_uri->path;
$endpoint = $config->endpoint;
$endpoint .= '*' unless $endpoint =~ m/\*/;
$endpoint =~ s{\*}{$local_path};
$endpoint .= '?' . $local_uri->query if $local_uri->query;
}
my $u = $self->_append_query_params( $endpoint, @args );
return "$u";
}
sub _append_query_params {
my $self = shift;
my $u = URI->new(shift);
my @args = @_;
foreach my $next (@args) {
$u->query_param_append( split( /=/, $next, 2 ) );
}
return $u;
}
sub response {
return shift->_rest_client->{_res} || undef;
}
sub has_response_content {
my $self = shift;
return $self->response->content_length
|| length( $self->response->content );
}
sub response_data {
my $self = shift;
my $response = $self->response;
if ( my $content_type = $response->header('Content-type') ) {
foreach my $h ( $self->content_handlers ) {
if ( $h->can_deserialize($content_type) ) {
return $h->deserialize( $response->content );
}
}
}
return $response->decoded_content;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
App::Presto::Client - The REST client
=head1 VERSION
version 0.010
=head1 AUTHORS
=over 4
=item *
Brian Phillips <bphillips@cpan.org>
=item *
Matt Perry <matt@mattperry.com> (current maintainer)
=back
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Brian Phillips and Shutterstock Images (http://shutterstock.com).
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.929 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )