Skip to content

Commit

Permalink
[api] Added proxy support and improved uri path
Browse files Browse the repository at this point in the history
  • Loading branch information
pksunkara committed Aug 15, 2012
1 parent 29c6eaf commit 864c884
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/director-reflector.js
@@ -1,20 +1,27 @@
var client = exports,
utile = require('utile'),
traverse = require('traverse');
traverse = require('traverse'),
request = require('request');

client.Client = function (options) {
var self = this;

options = options || {};

options.port = options.port || 8000;
options.host = options.host || "localhost";
self.basePath = "http://" + options.host + ':' + options.port;
if (!options.uri) {
options.port = options.port || 8000;
options.host = options.host || "localhost";
self.basePath = "http://" + options.host + ':' + options.port;
} else {
self.basePath = options.uri;
}

if(typeof options.username !== "undefined" && typeof options.password !== "undefined") {
self.authorization = utile.base64.encode(options.username + ':' + options.password);
}

request.defaults({ proxy: options.proxy });

return self;
}

Expand Down Expand Up @@ -91,8 +98,6 @@ client.id = function (id) {
return function(){};
}

var request = require('request');

client.Client.prototype.request = function (path, verbs, args) {

var self = this;
Expand Down Expand Up @@ -214,4 +219,4 @@ client.toJSON = function (router) {
}
}
return JSON.stringify({ routes: _routes });
};
};

0 comments on commit 864c884

Please sign in to comment.