Skip to content

Commit 83ad913

Browse files
committed
Merge pull request #48 from rosette-api/develop
1.1.4
2 parents 4593246 + fac2d38 commit 83ad913

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

examples/language.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ parser.addArgument(["--url"], {help: "Rosette API alt-url", required: false});
1212
var args = parser.parseArgs();
1313
var api = new Api(args.key, args.url);
1414
var endpoint = "language";
15+
var appHeader = [];
16+
appHeader[0] = "X-RosetteAPI-App"
17+
appHeader[1] = "app";
18+
api.parameters.customHeaders = [appHeader];
1519

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

lib/parameters.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ function parameters() {
7373
//morphology
7474
this.morphology = null;
7575

76+
//custom headers
77+
this.customHeaders = null;
78+
7679
}
7780

7881
/**
@@ -103,11 +106,12 @@ parameters.prototype.loadParams = function() {
103106
"short-string": this.shortString,
104107
"morphology": this.morphology,
105108
"_maxRetries": this.maxRetries,
106-
"_msInterval": this.msInterval
109+
"_msInterval": this.msInterval,
110+
"customHeaders": this.customHeaders
107111
};
108112

109113
for (var key in paramJSON) {
110-
if (key.substring(0, 1) !== '_' && paramJSON[key] != null) {
114+
if (key.substring(0, 1) !== '_' && paramJSON[key] != null && key != "customHeaders") {
111115
tempJSON[key] = paramJSON[key];
112116
}
113117
}

lib/rosetteRequest.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ rosetteRequest.prototype.makeRequest = function(requestType, userKey, urlParts,
7575
headers["X-RosetteAPI-Key"] = userKey;
7676
}
7777

78+
if(parameters.customHeaders != null){
79+
parameters.customHeaders.forEach( function(element, index) {
80+
headers[element[0]] = element[1];
81+
});
82+
83+
}
84+
7885
var options = {
7986
hostname: urlParts.hostname,
8087
path: urlParts.path,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rosette-api",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "Rosette API Node.js client SDK",
55
"main": "index",
66
"directories": {

0 commit comments

Comments
 (0)