Added global headers option
This commit is contained in:
4
index.js
4
index.js
@ -50,6 +50,7 @@ class Client extends EventEmitter {
|
|||||||
compression: false,
|
compression: false,
|
||||||
ssl: null,
|
ssl: null,
|
||||||
agent: null,
|
agent: null,
|
||||||
|
headers: {},
|
||||||
nodeFilter: null,
|
nodeFilter: null,
|
||||||
nodeWeighter: null,
|
nodeWeighter: null,
|
||||||
nodeSelector: 'round-robin'
|
nodeSelector: 'round-robin'
|
||||||
@ -85,7 +86,8 @@ class Client extends EventEmitter {
|
|||||||
sniffOnConnectionFault: options.sniffOnConnectionFault,
|
sniffOnConnectionFault: options.sniffOnConnectionFault,
|
||||||
sniffEndpoint: options.sniffEndpoint,
|
sniffEndpoint: options.sniffEndpoint,
|
||||||
suggestCompression: options.suggestCompression,
|
suggestCompression: options.suggestCompression,
|
||||||
compression: options.compression
|
compression: options.compression,
|
||||||
|
headers: options.headers
|
||||||
})
|
})
|
||||||
|
|
||||||
const apis = buildApi({
|
const apis = buildApi({
|
||||||
|
|||||||
@ -27,6 +27,7 @@ class Transport {
|
|||||||
this.requestTimeout = toMs(opts.requestTimeout)
|
this.requestTimeout = toMs(opts.requestTimeout)
|
||||||
this.suggestCompression = opts.suggestCompression === true
|
this.suggestCompression = opts.suggestCompression === true
|
||||||
this.compression = opts.compression || false
|
this.compression = opts.compression || false
|
||||||
|
this.headers = opts.headers || {}
|
||||||
this.sniffInterval = opts.sniffInterval
|
this.sniffInterval = opts.sniffInterval
|
||||||
this.sniffOnConnectionFault = opts.sniffOnConnectionFault
|
this.sniffOnConnectionFault = opts.sniffOnConnectionFault
|
||||||
this.sniffEndpoint = opts.sniffEndpoint
|
this.sniffEndpoint = opts.sniffEndpoint
|
||||||
@ -82,7 +83,8 @@ class Transport {
|
|||||||
return callback(new NoLivingConnectionsError('There are not living connections'), result)
|
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
|
// handle json body
|
||||||
if (params.body != null) {
|
if (params.body != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user