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
Original file line number Original file line Diff line number Diff line change
@@ -1,20 +1,27 @@
var client = exports, var client = exports,
utile = require('utile'), utile = require('utile'),
traverse = require('traverse'); traverse = require('traverse'),
request = require('request');


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


options = options || {}; options = options || {};


options.port = options.port || 8000; if (!options.uri) {
options.host = options.host || "localhost"; options.port = options.port || 8000;
self.basePath = "http://" + options.host + ':' + options.port; 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") { if(typeof options.username !== "undefined" && typeof options.password !== "undefined") {
self.authorization = utile.base64.encode(options.username + ':' + options.password); self.authorization = utile.base64.encode(options.username + ':' + options.password);
} }


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

return self; return self;
} }


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


var request = require('request');

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


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

0 comments on commit 864c884

Please sign in to comment.