Skip to content

Commit

Permalink
Add optional settings argument to Controller.
Browse files Browse the repository at this point in the history
Controller extensions broke in 1d46eae
because the settings arguments was not passed.
  • Loading branch information
RubenVerborgh committed Oct 26, 2016
1 parent fdfcb54 commit 9bfc944
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/controllers/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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();
};

Expand Down
2 changes: 0 additions & 2 deletions test/controllers/Controller-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9bfc944

Please sign in to comment.