summaryrefslogtreecommitdiff
path: root/lib/MooseX/Net/API/Role
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-06-24 11:06:31 +0200
committerfranck cuny <franck@lumberjaph.net>2010-06-24 11:06:31 +0200
commitec48e1ecc95c17e792b4f576c585275d4e871e4d (patch)
tree7d1c71bccaf62b27a9d9e478b06b6470fd96f6ca /lib/MooseX/Net/API/Role
parentparams can be strict or no strict (diff)
downloadnet-http-api-ec48e1ecc95c17e792b4f576c585275d4e871e4d.tar.gz
add strict and alter what params_in_url does
Diffstat (limited to 'lib/MooseX/Net/API/Role')
-rw-r--r--lib/MooseX/Net/API/Role/Request.pm17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/MooseX/Net/API/Role/Request.pm b/lib/MooseX/Net/API/Role/Request.pm
index 5adb43c..13221d3 100644
--- a/lib/MooseX/Net/API/Role/Request.pm
+++ b/lib/MooseX/Net/API/Role/Request.pm
@@ -28,18 +28,23 @@ sub http_request {
my $request;
- if ( $method =~ /^(?:GET|DELETE)$/ || $params_in_url ) {
+ if ($method =~ /^(?:GET|DELETE)$/) {
$uri->query_form(%$args);
- $request = HTTP::Request->new( $method => $uri );
+ $request = HTTP::Request->new($method => $uri);
}
- elsif ( $method =~ /^(?:POST|PUT)$/ ) {
- $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" );
+ die MooseX::Net::API::Error->new(reason => "$method is not defined");
}
$request->header(