Skip to content

Commit

Permalink
Merge pull request #48 from rosette-api/develop
Browse files Browse the repository at this point in the history
1.1.4
  • Loading branch information
SamHausmann committed Jun 1, 2016
2 parents 4593246 + fac2d38 commit 83ad913
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions examples/language.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ parser.addArgument(["--url"], {help: "Rosette API alt-url", required: false});
var args = parser.parseArgs();
var api = new Api(args.key, args.url);
var endpoint = "language";
var appHeader = [];
appHeader[0] = "X-RosetteAPI-App"
appHeader[1] = "app";
api.parameters.customHeaders = [appHeader];

var content = "Por favor Señorita, says the man.";

Expand Down
8 changes: 6 additions & 2 deletions lib/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ function parameters() {
//morphology
this.morphology = null;

//custom headers
this.customHeaders = null;

}

/**
Expand Down Expand Up @@ -103,11 +106,12 @@ parameters.prototype.loadParams = function() {
"short-string": this.shortString,
"morphology": this.morphology,
"_maxRetries": this.maxRetries,
"_msInterval": this.msInterval
"_msInterval": this.msInterval,
"customHeaders": this.customHeaders
};

for (var key in paramJSON) {
if (key.substring(0, 1) !== '_' && paramJSON[key] != null) {
if (key.substring(0, 1) !== '_' && paramJSON[key] != null && key != "customHeaders") {
tempJSON[key] = paramJSON[key];
}
}
Expand Down
7 changes: 7 additions & 0 deletions lib/rosetteRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ rosetteRequest.prototype.makeRequest = function(requestType, userKey, urlParts,
headers["X-RosetteAPI-Key"] = userKey;
}

if(parameters.customHeaders != null){
parameters.customHeaders.forEach( function(element, index) {
headers[element[0]] = element[1];
});

}

var options = {
hostname: urlParts.hostname,
path: urlParts.path,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rosette-api",
"version": "1.1.3",
"version": "1.1.4",
"description": "Rosette API Node.js client SDK",
"main": "index",
"directories": {
Expand Down

0 comments on commit 83ad913

Please sign in to comment.