Skip to content

Commit 4afac1d

Browse files
author
James Haley
committed
Auth can now be specified per request
1 parent e8e6cf3 commit 4afac1d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/batchelor.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ var request = require('request'),
8383

8484
// Give each request an id so we can identify the response
8585
var rack = hat.rack(),
86-
requestId = options.requestId || 'Batchelor_' + rack();
86+
requestId = options.requestId || 'Batchelor_' + rack();
8787

8888
// Save out request specific callback
8989
if (!!options.callback) {
@@ -135,6 +135,11 @@ var request = require('request'),
135135
'body': requestPart.method + ' ' + requestPart.path + '\n'
136136
};
137137

138+
// Check if this part needs it's own auth
139+
if ((!!requestPart.auth) && (!!requestPart.auth.bearer)) {
140+
requestSettings.body += 'Authorization: Bearer ' + requestPart.auth.bearer + '\n';
141+
}
142+
138143
// Replace body with a request if this isn't a GET
139144
if (requestPart.method !== 'GET') {
140145
requestSettings.body = requestPart.method + ' ' + requestPart.path + '\n' +

0 commit comments

Comments
 (0)