Skip to content

Commit

Permalink
Added global headers option
Browse files Browse the repository at this point in the history
  • Loading branch information
delvedor committed Feb 20, 2019
1 parent e9cc032 commit 974bf0a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Client extends EventEmitter {
compression: false,
ssl: null,
agent: null,
headers: {},
nodeFilter: null,
nodeWeighter: null,
nodeSelector: 'round-robin'
Expand Down Expand Up @@ -85,7 +86,8 @@ class Client extends EventEmitter {
sniffOnConnectionFault: options.sniffOnConnectionFault,
sniffEndpoint: options.sniffEndpoint,
suggestCompression: options.suggestCompression,
compression: options.compression
compression: options.compression,
headers: options.headers
})

const apis = buildApi({
Expand Down
4 changes: 3 additions & 1 deletion lib/Transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Transport {
this.requestTimeout = toMs(opts.requestTimeout)
this.suggestCompression = opts.suggestCompression === true
this.compression = opts.compression || false
this.headers = opts.headers || {}
this.sniffInterval = opts.sniffInterval
this.sniffOnConnectionFault = opts.sniffOnConnectionFault
this.sniffEndpoint = opts.sniffEndpoint
Expand Down Expand Up @@ -82,7 +83,8 @@ class Transport {
return callback(new NoLivingConnectionsError('There are not living connections'), result)
}

const headers = options.headers || {}
// TODO: make this assignment FAST
const headers = Object.assign({}, this.headers, options.headers)

// handle json body
if (params.body != null) {
Expand Down

0 comments on commit 974bf0a

Please sign in to comment.