Skip to content

Commit

Permalink
Migrate implementation to match express .handle
Browse files Browse the repository at this point in the history
  • Loading branch information
retrohacker committed Mar 13, 2019
1 parent d4cbe83 commit d57ef12
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/server.js
Expand Up @@ -838,6 +838,8 @@ Server.prototype._onRequest = function _onRequest(req, res) {
}
};

Server.prototype.handle = Server.prototype._onRequest;

/**
* Run pre handlers
*
Expand Down
21 changes: 21 additions & 0 deletions test/server.test.js
Expand Up @@ -2557,3 +2557,24 @@ test('should have proxy event handlers as instance', function(t) {
t.end();
});
});

test('handle should invoke restify', function(t) {
var RESTIFY_SERVER = SERVER;
SERVER = http.createServer();
SERVER.on('request', function(req, res) {
return RESTIFY_SERVER.handle(req, res);
});
RESTIFY_SERVER.get('/', function(req, res, next) {
res.send(413);
next();
});
RESTIFY_SERVER.close(function() {
SERVER.listen(PORT, function() {
CLIENT.get('/', function(err, _, res) {
t.ok(err);
t.equal(res.statusCode, 413);
t.done();
});
});
});
});

0 comments on commit d57ef12

Please sign in to comment.