Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ app.handle = function(req, res, done) {
app.use = function use(fn) {
var offset = 0;
var path = '/';
var self = this;

// default path to '/'
if (typeof fn !== 'function') {
Expand All @@ -180,7 +179,7 @@ app.use = function use(fn) {

debug('.use app under %s', path);
fn.mountpath = path;
fn.parent = self;
fn.parent = this;

// restore .app property on req and res
router.use(path, function mounted_app(req, res, next) {
Expand All @@ -193,8 +192,8 @@ app.use = function use(fn) {
});

// mounted an app
fn.emit('mount', self);
});
fn.emit('mount', this);
}, this);

return this;
};
Expand Down Expand Up @@ -268,17 +267,16 @@ app.engine = function(ext, fn){
*/

app.param = function(name, fn){
var self = this;
self.lazyrouter();
this.lazyrouter();

if (Array.isArray(name)) {
name.forEach(function(key) {
self.param(key, fn);
});
this.param(key, fn);
}, this);
return this;
}

self._router.param(name, fn);
this._router.param(name, fn);
return this;
};

Expand Down
3 changes: 1 addition & 2 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,7 @@ res.sendFile = function sendFile(path, options, fn) {

res.sendfile = function(path, options, fn){
options = options || {};
var self = this;
var req = self.req;
var req = this.req;
var next = this.req.next;
var done;

Expand Down
7 changes: 3 additions & 4 deletions lib/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ proto.process_params = function(layer, called, req, res, done) {
proto.use = function use(fn) {
var offset = 0;
var path = '/';
var self = this;

// default path to '/'
if (typeof fn !== 'function') {
Expand All @@ -427,15 +426,15 @@ proto.use = function use(fn) {
debug('use %s %s', path, fn.name || '<anonymous>');

var layer = new Layer(path, {
sensitive: self.caseSensitive,
sensitive: this.caseSensitive,
strict: false,
end: false
}, fn);

layer.route = undefined;

self.stack.push(layer);
});
this.stack.push(layer);
}, this);

return this;
};
Expand Down
20 changes: 9 additions & 11 deletions lib/router/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ Route.prototype.dispatch = function(req, res, done){
*/

Route.prototype.all = function(){
var self = this;
var callbacks = utils.flatten([].slice.call(arguments));
callbacks.forEach(function(fn) {
if (typeof fn !== 'function') {
Expand All @@ -143,16 +142,15 @@ Route.prototype.all = function(){
var layer = Layer('/', {}, fn);
layer.method = undefined;

self.methods._all = true;
self.stack.push(layer);
});
this.methods._all = true;
this.stack.push(layer);
}, this);

return self;
return this;
};

methods.forEach(function(method){
Route.prototype[method] = function(){
var self = this;
var callbacks = utils.flatten([].slice.call(arguments));

callbacks.forEach(function(fn) {
Expand All @@ -162,14 +160,14 @@ methods.forEach(function(method){
throw new Error(msg);
}

debug('%s %s', method, self.path);
debug('%s %s', method, this.path);

var layer = Layer('/', {}, fn);
layer.method = method;

self.methods[method] = true;
self.stack.push(layer);
});
return self;
this.methods[method] = true;
this.stack.push(layer);
}, this);
return this;
};
});