Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add shortcut for PATCH requests #71

Merged
merged 1 commit into from

2 participants

Greg Guthe Andrew Young
Greg Guthe

No description provided.

Andrew Young ayoung merged commit 42eacac into from
Andrew Young
Collaborator

Thanks. Pull this in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 21, 2012
  1. Add shortcut for PATCH requests

    Greg Guthe authored
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 0 deletions.
  1. +8 −0 lib/restler.js
  2. +7 −0 test/restler.js
8 lib/restler.js
View
@@ -274,6 +274,10 @@ function get(url, options) {
return request(url, shortcutOptions(options, 'GET'));
}
+function patch(url, options) {
+ return request(url, shortcutOptions(options, 'PATCH'));
+}
+
function post(url, options) {
return request(url, shortcutOptions(options, 'POST'));
}
@@ -418,6 +422,9 @@ mixin(Service.prototype, {
get: function(path, options) {
return get(this._url(path), this._withDefaults(options));
},
+ patch: function(path, options) {
+ return patch(this._url(path), this._withDefaults(options));
+ },
put: function(path, options) {
return put(this._url(path), this._withDefaults(options));
},
@@ -449,6 +456,7 @@ mixin(exports, {
request: request,
service: service,
get: get,
+ patch: patch,
post: post,
put: put,
del: del,
7 test/restler.js
View
@@ -82,6 +82,13 @@ module.exports['Basic'] = {
});
},
+ 'Should PATCH': function(test) {
+ rest.patch(host).on('complete', function(data) {
+ test.re(data, /^PATCH/, 'should be PATCH');
+ test.done();
+ });
+ },
+
'Should PUT': function(test) {
rest.put(host).on('complete', function(data) {
test.re(data, /^PUT/, 'should be PUT');
Something went wrong with that request. Please try again.