Skip to content

Instantly share code, notes, and snippets.

@vitohuang
Created September 7, 2010 22:11
Show Gist options
  • Save vitohuang/569233 to your computer and use it in GitHub Desktop.
Save vitohuang/569233 to your computer and use it in GitHub Desktop.
var haml = require('hamljs'); var app = require('express').createServer();
var express = require('express');
app.configure('development', function() {
app.use(express.methodOverride());
app.use(app.router);
app.use(express.logger());
app.use(express.bodyDecoder());
app.use(express.staticProvider(__dirname+'/public'));
});
app.get("/", function(req,res) {
console.log("A client connected to this HTTP server");
res.send("Bye");
});
app.post("/post", function(req, res) {
console.log("A post message");
console.dir(req);
console.log("get the incoming name");
console.log(req.param.name);
res.send("end of post");
});
app.listen(8888);
@tj
Copy link

tj commented Sep 7, 2010

Few notes:

  • methodOverride() should be below bodyDecoder() so that it can use the parsed body to check "_method"
  • logger() should be first so that it can wrap all middleware
  • app.router should be below bodyDecoder() and above staticProvider() so that you can intercept files if needed, and this is the source of your issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment