Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Support for method PATCH #13

Closed
wants to merge 2 commits into from

2 participants

@omega

GitHub v3 api uses a PATCH method to update objects. This rather small patch adds support for that I think.

@franckcuny
Owner

Nice, I was planning to add this method at some point. I'll take a look tonight and let you know.

@ashb ashb closed this in 7c15b35
@ashb ashb referenced this pull request from a commit
@ashb ashb v0.06
    - Fix random test failure in t/spore-method/base.t related to random hash
      ordering in perl 5.17.6+ (#19)
    - Add support for PATCH HTTP method (#13, Andreas Marienborg)
    - Allow anonymous subs to be used as middleware (Brian Phillips)
    - Refactor internals of Net::HTTP::Spore building of specs to allow easier
      subclassing
14c5d3b
@ashb ashb referenced this pull request from a commit
@ashb ashb v0.06
    - Fix random test failure in t/spore-method/base.t related to random hash
      ordering in perl 5.17.6+ (#19)
    - Add support for PATCH HTTP method (#13, Andreas Marienborg)
    - Allow anonymous subs to be used as middleware (Brian Phillips)
    - Refactor internals of Net::HTTP::Spore building of specs to allow easier
      subclassing
c58f833
@ashb ashb referenced this pull request from a commit
@ashb ashb v0.06
    - Fix random test failure in t/spore-method/base.t related to random hash
      ordering in perl 5.17.6+ (#19)
    - Add support for PATCH HTTP method (#13, Andreas Marienborg)
    - Allow anonymous subs to be used as middleware (Brian Phillips)
    - Refactor internals of Net::HTTP::Spore building of specs to allow easier
      subclassing
7847971
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 5 deletions.
  1. +3 −3 lib/Net/HTTP/Spore/Meta/Method.pm
  2. +10 −2 t/spore-method/payload.t
View
6 lib/Net/HTTP/Spore/Meta/Method.pm
@@ -17,7 +17,7 @@ subtype UriPath
=> where { $_ =~ m!^/! }
=> message {"path must start with /"};
-enum Method => qw(OPTIONS HEAD GET POST PUT DELETE TRACE);
+enum Method => qw(OPTIONS HEAD GET POST PUT DELETE TRACE PATCH);
subtype 'JSON::XS::Boolean' => as 'JSON::XS::Boolean';
subtype 'JSON::PP::Boolean' => as 'JSON::PP::Boolean';
@@ -144,10 +144,10 @@ sub wrap {
: delete $method_args{payload};
if ( $payload
- && ( $method->method !~ /^P(?:OS|U)T$/i ) )
+ && ( $method->method !~ /^(?:POST|PUT|PATCH)$/i ) )
{
die Net::HTTP::Spore::Response->new( 599, [],
- { error => "payload requires a PUT or POST method" },
+ { error => "payload requires a PUT, PATCH or POST method" },
);
}
View
12 t/spore-method/payload.t
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 4;
+use Test::More tests => 6;
use Test::Exception;
@@ -15,6 +15,11 @@ my $api_with_payload = {
path => '/user',
required_payload => 1,
},
+ update_user => {
+ method => 'PATCH',
+ path => '/user',
+ required_payload => 1,
+ },
list_user => {
method => 'GET',
path => '/user',
@@ -30,4 +35,7 @@ dies_ok { $obj->create_user(); };
like $@->body->{error}, qr/this method require a payload/;
dies_ok { $obj->list_user( payload => {} ) };
-like $@->body->{error}, qr/payload requires a PUT or POST method/;
+like $@->body->{error}, qr/payload requires a PUT, PATCH or POST method/;
+
+dies_ok { $obj->update_user(); };
+like $@->body->{error}, qr/this method require a payload/;
Something went wrong with that request. Please try again.