Skip to content

Commit

Permalink
feat: Add callback support for Gofer
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Krems committed Apr 6, 2016
1 parent 04ed5ba commit 28b5a6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/gofer.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ function applyOptionMapper(options, mapper) {
}

function fetchWithDefaults(defaults) {
return function withDefaults(uri, options) {
return function withDefaults(uri, options, callback) {
options = options || {};
var endpointName = options.endpointName || defaults.endpointName;
var mergedOptions = merge({}, this.defaults, defaults,
this.defaults.endpointDefaults[endpointName],
options);
var mappedOptions = this._mappers.reduce(applyOptionMapper, mergedOptions);
return fetch(uri, mappedOptions);
return fetch(uri, mappedOptions, callback);
};
}

Expand Down
7 changes: 7 additions & 0 deletions test/gofer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ describe('gofer', function () {
it('can fetch something', function () {
return gofer.get('/echo');
});

it('exposes the legacy mode interface', function (done) {
gofer.get('/echo', {}, function (error, body) {
assert.truthy(body);
done(error);
});
});
});

describe('sub-class', function () {
Expand Down

0 comments on commit 28b5a6a

Please sign in to comment.