Skip to content

Commit

Permalink
Adding defaults call.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed Feb 4, 2011
1 parent cb403a4 commit a3c80f9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,27 @@ function request (options, callback) {
return r;
}


module.exports = request;

request.defaults = function (options) {
var def = function (method) {
var d = function (opts, callback) {
for (i in options) {
if (!opts[i]) opts[i] = options[i];
return method(opts, callback);
}
}
return d;
}
de = def(request);
de.get = def(request.get);
de.post = def(request.post);
de.put = def(request.put);
de.head = def(request.head);
return d;
}

request.get = request;
request.post = function (options, callback) {
options.method = 'POST';
Expand Down

0 comments on commit a3c80f9

Please sign in to comment.