Skip to content

Commit

Permalink
Merge pull request #37 from hudson-taylor/transport-options
Browse files Browse the repository at this point in the history
Allow passing custom options to transport calls
  • Loading branch information
SomeoneWeird committed Mar 15, 2018
2 parents 57cc051 + f56b8db commit 5b4237b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/client.js
Expand Up @@ -92,7 +92,7 @@ Client.prototype.disconnect = function (done) {
}, done)
}

Client.prototype.call = function (service, method, data, callback) {
Client.prototype.call = function (service, method, data, callback, opts = {}) {
let context = {
service,
method
Expand Down Expand Up @@ -198,7 +198,7 @@ Client.prototype.call = function (service, method, data, callback) {
return finish(data)
}
})
})
}, opts)
})

if (returnPromise) {
Expand Down
20 changes: 20 additions & 0 deletions test/client.js
Expand Up @@ -347,6 +347,26 @@ describe('Client', function () {
return done()
})
})

it('should pass extra options', function (done) {
let services = {
s1: mockTransport({
call (method, data, callback, opts) {
return callback(null, opts)
}
})()
}

let client = new Client(services)

client.call('s1', 'test', {}, function (err, data) {
assert.ifError(err)
assert.equal(data.myOption, 'something')
return done()
}, {
myOption: 'something'
})
})
})

describe('middleware', function () {
Expand Down

0 comments on commit 5b4237b

Please sign in to comment.