Created
March 18, 2013 18:48
-
-
Save thatmarvin/5189720 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var express = require('express') | |
, app = module.exports = express.createServer(); | |
// Configuration | |
app.configure(function () { | |
app.use(app.router); | |
}); | |
function Controller(model) { | |
this.model = model; | |
} | |
Controller.prototype.find = function (req, res, next) { | |
res.send(typeof this); | |
} | |
var c = new Controller({}); | |
// "this" is undefined in Express 2 | |
app.get('/1', c.find); | |
// "this" is correctly returned as an object | |
app.get('/2', function (req, res, next) { | |
c.find(req, res, next); | |
}); | |
// Start server | |
app.listen(3000, function () { | |
console.log('Express server listening on port %d in %s mode', app.address().port, app.settings.env); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment