Skip to content
Browse files

[api] Added proxy support and improved uri path

  • Loading branch information...
1 parent 29c6eaf commit 864c884c29f7392b2e18801060b2bd1cfb698f6d @pksunkara pksunkara committed Aug 16, 2012
Showing with 12 additions and 7 deletions.
  1. +12 −7 lib/director-reflector.js
View
19 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;
}
@@ -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;
@@ -214,4 +219,4 @@ client.toJSON = function (router) {
}
}
return JSON.stringify({ routes: _routes });
-};
+};

0 comments on commit 864c884

Please sign in to comment.
Something went wrong with that request. Please try again.