Skip to content

Instantly share code, notes, and snippets.

@seratch
Created November 30, 2011 10:49
Show Gist options
  • Save seratch/1408644 to your computer and use it in GitHub Desktop.
Save seratch/1408644 to your computer and use it in GitHub Desktop.
myFirstMiddlewareForConnect.js
// #nodejyuku
var connect = require("connect");
// my first middleware
var requestDumper = function() {
return function(req, res, next) {
console.log(req);
next();
};
};
connect.createServer(
connect.logger(),
requestDumper(),
function(req, res){
var body = 'Hello World';
res.setHeader('Content-Length', body.length);
res.end(body);
}
).listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment