Skip to content

Commit

Permalink
Merge pull request #7 from adamkaplan/master
Browse files Browse the repository at this point in the history
Support for non-standard ports and cleaner unsecure auth
  • Loading branch information
mansilladev committed Oct 18, 2011
2 parents 04d86bc + 5e9f9d4 commit f2796a6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app.js
Expand Up @@ -298,14 +298,19 @@ function processRequest(req, res, next) {
} }
} }


var baseHostInfo = apiConfig.baseURL.split(':');
var baseHostUrl = baseHostInfo[0],
baseHostPort = (baseHostInfo.length > 1) ? baseHostInfo[1] : "";

var paramString = query.stringify(params), var paramString = query.stringify(params),
privateReqURL = apiConfig.protocol + '://' + apiConfig.baseURL + apiConfig.privatePath + methodURL + '?' + paramString; privateReqURL = apiConfig.protocol + '://' + apiConfig.baseURL + apiConfig.privatePath + methodURL + ((paramString.length > 0) ? '?' + paramString : ""),
options = { options = {
headers: {}, headers: {},
protocol: apiConfig.protocol, protocol: apiConfig.protocol,
host: apiConfig.baseURL, host: baseHostUrl,
port: baseHostPort,
method: httpMethod, method: httpMethod,
path: apiConfig.publicPath + methodURL + '?' + paramString path: apiConfig.publicPath + methodURL + ((paramString.length > 0) ? '?' + paramString : "")
}; };


if (apiConfig.oauth) { if (apiConfig.oauth) {
Expand Down Expand Up @@ -455,7 +460,7 @@ function processRequest(req, res, next) {
console.log('Unsecured Call'); console.log('Unsecured Call');


// Add API Key to params, if any. // Add API Key to params, if any.
if (apiKey != '') { if (apiKey != '' && apiKey != 'undefined' && apiKey != undefined) {
options.path += '&' + apiConfig.keyParam + '=' + apiKey; options.path += '&' + apiConfig.keyParam + '=' + apiKey;
} }


Expand Down

0 comments on commit f2796a6

Please sign in to comment.