Skip to content

Commit a5b76f2

Browse files
committed
fix: java integration
1 parent 785b593 commit a5b76f2

File tree

6 files changed

+47
-36
lines changed

6 files changed

+47
-36
lines changed

src/targets/java/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
3-
module.exports = require('require-directory')(module);
4-
1+
'use strict'
52

3+
module.exports = require('require-directory')(module)

src/targets/java/info.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
'use strict';
1+
'use strict'
22

33
module.exports = {
44
key: 'java',
55
title: 'JAVA',
66
extname: '.java',
77
default: 'unirest'
8-
};
8+
}

src/targets/java/unirest.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
'use strict';
1+
'use strict'
22

3-
var util = require('util');
3+
var util = require('util')
44

5-
module.exports = function(options) {
6-
var self = this;
5+
module.exports = function (options) {
6+
var self = this
77
var opts = util._extend({
8-
indent : ' '
9-
}, options);
8+
indent: ' '
9+
}, options)
1010

11-
var code = [];
11+
var code = []
1212

13-
var methods = [ "GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS" ];
13+
var methods = [ 'GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS' ]
1414

15-
if (methods.indexOf(self.source.method.toUpperCase()) == -1) {
16-
return self.source.method.toUpperCase() + " method not supported by Unirest liabrary.";
15+
if (methods.indexOf(self.source.method.toUpperCase()) === -1) {
16+
return self.source.method.toUpperCase() + ' method not supported by Unirest liabrary.'
1717
}
1818

19-
code.push(util.format('HttpResponse<String> response = Unirest.%s("%s")', self.source.method.toLowerCase(), self.source.fullUrl));
19+
code.push(util.format('HttpResponse<String> response = Unirest.%s("%s")', self.source.method.toLowerCase(), self.source.fullUrl))
2020

2121
// Add headers, including the cookies
22-
var headers = Object.keys(self.source.allHeaders);
22+
var headers = Object.keys(self.source.allHeaders)
2323

2424
// construct headers
2525
if (headers.length) {
26-
headers.map(function(key) {
27-
code.push(util.format('.header("%s", "%s")', key, self.source.allHeaders[key]));
28-
});
26+
headers.map(function (key) {
27+
code.push(util.format('.header("%s", "%s")', key, self.source.allHeaders[key]))
28+
})
2929
}
3030

3131
// construct postdata
3232
if (self.source.postData) {
3333
if (self.source.postData.text) {
34-
code.push(util.format('.body(%s)', JSON.stringify(self.source.postData.text)));
34+
code.push(util.format('.body(%s)', JSON.stringify(self.source.postData.text)))
3535
}
3636
}
3737

38-
code.push(".asString();");
39-
return code.join('\n' + opts.indent);
40-
};
38+
code.push('.asString();')
39+
return code.join('\n' + opts.indent)
40+
}
4141

4242
module.exports.info = {
43-
key : 'unirest',
44-
title : 'JAVA',
45-
link : 'http://unirest.io/java.html',
46-
description : 'Unirest Java interface'
47-
};
43+
key: 'unirest',
44+
title: 'JAVA',
45+
link: 'http://unirest.io/java.html',
46+
description: 'Unirest Java interface'
47+
}

test/fixtures/available-targets.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,19 @@
115115
"description": "Golang HTTP client request"
116116
}
117117
]
118+
},
119+
{
120+
"key": "java",
121+
"title": "JAVA",
122+
"extname": ".java",
123+
"default": "unirest",
124+
"clients": [
125+
{
126+
"key": "unirest",
127+
"title": "JAVA",
128+
"link": "http://unirest.io/java.html",
129+
"description": "Unirest Java interface"
130+
}
131+
]
118132
}
119133
]

test/tests/java/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
'use strict';
1+
'use strict'
22

3-
module.exports = require('require-directory')(module);
3+
module.exports = require('require-directory')(module)

test/tests/java/unirest.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
'use strict';
1+
'use strict'
22

3-
require('should');
3+
require('should')
44

5-
module.exports = function (snippet, fixtures) {
6-
};
5+
module.exports = function (snippet, fixtures) {}

0 commit comments

Comments
 (0)