aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node/index.js
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2015-08-20 11:27:05 -0700
committerGravatar murgatroid99 <mlumish@google.com>2015-08-20 11:27:05 -0700
commit84e3cdeb970dae5840ab0453536a7a53428a8e65 (patch)
tree00f71a2e445269bfe273b6a98181ea87480bc1c7 /src/node/index.js
parent89bede02f16905eb48b71710dc4ea2542b3a5ca1 (diff)
Added new Metadata class to abstract over internal representation and normalize keys
Diffstat (limited to 'src/node/index.js')
-rw-r--r--src/node/index.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/node/index.js b/src/node/index.js
index 889b0ac0e9..51d3fa590c 100644
--- a/src/node/index.js
+++ b/src/node/index.js
@@ -41,6 +41,8 @@ var client = require('./src/client.js');
var server = require('./src/server.js');
+var Metadata = require('./src/metadata.js');
+
var grpc = require('bindings')('grpc');
/**
@@ -107,18 +109,12 @@ exports.getGoogleAuthDelegate = function getGoogleAuthDelegate(credential) {
* @param {function(Error, Object)} callback
*/
return function updateMetadata(authURI, metadata, callback) {
- metadata = _.clone(metadata);
- if (metadata.Authorization) {
- metadata.Authorization = _.clone(metadata.Authorization);
- } else {
- metadata.Authorization = [];
- }
credential.getRequestMetadata(authURI, function(err, header) {
if (err) {
callback(err);
return;
}
- metadata.Authorization.push(header.Authorization);
+ metadata.add('authorization', header.Authorization);
callback(null, metadata);
});
};
@@ -130,6 +126,11 @@ exports.getGoogleAuthDelegate = function getGoogleAuthDelegate(credential) {
exports.Server = server.Server;
/**
+ * @see module:src/metadata
+ */
+exports.Metadata = Metadata;
+
+/**
* Status name to code number mapping
*/
exports.status = grpc.status;