Skip to content

Commit 52550b1

Browse files
committed
Move options handling to unit's Server constructor
1 parent d602948 commit 52550b1

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/nodejs/unit-http/http.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,7 @@ const {
1313
} = require('./http_server');
1414

1515
function createServer (options, requestHandler) {
16-
if (typeof options === 'function') {
17-
requestHandler = options;
18-
options = {};
19-
} else {
20-
stderr.write('createServer was called with an options object. Unit ignores this for the time being.');
21-
}
22-
23-
return new Server(requestHandler);
16+
return new Server(options, requestHandler);
2417
}
2518

2619
const http = require("http")

src/nodejs/unit-http/http_server.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,14 @@ ServerRequest.prototype._read = function _read(n) {
413413
};
414414

415415

416-
function Server(requestListener) {
416+
function Server(options, requestListener) {
417+
if (typeof options === 'function') {
418+
requestListener = options;
419+
options = {};
420+
} else {
421+
stderr.write('createServer was called with an options object. Unit ignores this for the time being.');
422+
}
423+
417424
EventEmitter.call(this);
418425

419426
this.unit = new unit_lib.Unit();

0 commit comments

Comments
 (0)