From 9bfc9441555166b619217e5b07a56b0d238731e7 Mon Sep 17 00:00:00 2001 From: Ruben Verborgh Date: Wed, 26 Oct 2016 20:25:10 +0200 Subject: [PATCH] Add optional settings argument to Controller. Controller extensions broke in 1d46eae00dbb708fe478e83eff0d09f6a40c70e0 because the settings arguments was not passed. --- lib/controllers/Controller.js | 6 +++--- test/controllers/Controller-test.js | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/controllers/Controller.js b/lib/controllers/Controller.js index d319d07e..1f12fd3a 100644 --- a/lib/controllers/Controller.js +++ b/lib/controllers/Controller.js @@ -30,7 +30,7 @@ Controller.extend = function extend(child) { }; // Tries to process the HTTP request -Controller.prototype.handleRequest = function (request, response, next) { +Controller.prototype.handleRequest = function (request, response, next, settings) { // Add a `parsedUrl` field to `request`, // containing the parsed request URL, resolved against the base URL if (!request.parsedUrl) { @@ -41,7 +41,7 @@ Controller.prototype.handleRequest = function (request, response, next) { // Try to handle the request var self = this; - try { this._handleRequest(request, response, done); } + try { this._handleRequest(request, response, done, settings); } catch (error) { done(error); } function done(error) { if (self) { @@ -55,7 +55,7 @@ Controller.prototype.handleRequest = function (request, response, next) { }; // Tries to process the HTTP request in an implementation-specific way -Controller.prototype._handleRequest = function (request, response, next) { +Controller.prototype._handleRequest = function (request, response, next, settings) { next(); }; diff --git a/test/controllers/Controller-test.js b/test/controllers/Controller-test.js index 64aa59e3..de6159c0 100644 --- a/test/controllers/Controller-test.js +++ b/test/controllers/Controller-test.js @@ -36,7 +36,6 @@ describe('Controller', function () { it('should call _handleRequest with request, response and next', function () { controller._handleRequest.should.have.been.calledOnce; var args = controller._handleRequest.getCall(0).args; - args.should.have.length(3); args[0].should.have.property('url'); args[1].should.be.an.instanceof(http.ServerResponse); args[2].should.be.an.instanceof(Function); @@ -75,7 +74,6 @@ describe('Controller', function () { it('should call _handleRequest with request, response and next', function () { controller._handleRequest.should.have.been.calledOnce; var args = controller._handleRequest.getCall(0).args; - args.should.have.length(3); args[0].should.have.property('url'); args[1].should.be.an.instanceof(http.ServerResponse); args[2].should.be.an.instanceof(Function);