Skip to content

Instantly share code, notes, and snippets.

@caridy
Created May 22, 2013 16:51
Show Gist options
  • Save caridy/5629094 to your computer and use it in GitHub Desktop.
Save caridy/5629094 to your computer and use it in GitHub Desktop.
overruling the method before calling express router
var express = require('express'),
app = express();
app.use(function (req, res, next) {
console.log(req);
req.method = 'GET';
next();
});
app.get('/', function (req, res, next) {
res.send({foo: 1});
});
// listening
app.set('port', 3000);
app.listen(app.get('port'), function () {
console.log("Server listening on port " +
app.get('port') + " in " + app.get('env') + " mode");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment