diff options
author | franck cuny <franck@lumberjaph.net> | 2010-07-16 16:12:32 +0200 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2010-07-16 16:12:32 +0200 |
commit | 5fdee9e79b5b6a72522bee59e4bd7c62506a43c7 (patch) | |
tree | 9e9f16e674310d95f7c39cea92e87aaa57d67746 /lib/MooseX/Net/API/Role/Request.pm | |
parent | another fix for path (diff) | |
download | moosex-net-api-5fdee9e79b5b6a72522bee59e4bd7c62506a43c7.tar.gz |
remove tests and old lib; use base net::http::api; DEPRECATED
Diffstat (limited to 'lib/MooseX/Net/API/Role/Request.pm')
-rw-r--r-- | lib/MooseX/Net/API/Role/Request.pm | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/lib/MooseX/Net/API/Role/Request.pm b/lib/MooseX/Net/API/Role/Request.pm deleted file mode 100644 index 13221d3..0000000 --- a/lib/MooseX/Net/API/Role/Request.pm +++ /dev/null @@ -1,79 +0,0 @@ -package MooseX::Net::API::Role::Request; - -# ABSTRACT: make HTTP request - -use Moose::Role; -use HTTP::Request; -use MooseX::Net::API::Error; -use MooseX::Types::URI qw(Uri); - -has api_base_url => ( - is => 'rw', - isa => Uri, - coerce => 1, - lazy => 1, - default => sub { - my $self = shift; - my $api_base_url = $self->meta->get_api_option('api_base_url'); - if (!$api_base_url) { - die MooseX::Net::API::Error->new( - reason => "'api_base_url' have not been defined"); - } - $api_base_url; - } -); - -sub http_request { - my ($self, $method, $uri, $params_in_url, $args) = @_; - - my $request; - - if ($method =~ /^(?:GET|DELETE)$/) { - $uri->query_form(%$args); - $request = HTTP::Request->new($method => $uri); - } - elsif ($method =~ /^(?:POST|PUT)$/) { - my $params = {}; - foreach my $key (@$params_in_url) { - $params->{$key} = $args->{$key} if exists $args->{$key}; - } - $uri->query_form(%$params) if $params; - - $request = HTTP::Request->new($method => $uri); - my $content = $self->serialize($args); - $request->content($content); - } - else { - die MooseX::Net::API::Error->new(reason => "$method is not defined"); - } - - $request->header( - 'Content-Type' => $self->content_type->{$self->api_format}->{value}) - if $self->api_format_mode eq 'content-type'; - - # XXX lwp hook! - my $result = $self->api_useragent->request($request); - return $result; -} - -1; - -=head1 SYNOPSIS - -=head1 DESCRIPTION - -=head2 METHODS - -=over 4 - -=item B<http_request> - -=back - -=head2 ATTRIBUTES - -=over 4 - -=item B<api_base_url> - -=back |