Skip to content

Instantly share code, notes, and snippets.

@michael
Created Nov 1, 2010
Embed
What would you like to do?
var express = require('express@1.0.0rc4');
var app = express.createServer();
var http = require('http');
var cradle = require('cradle@0.2.2');
var conn = new(cradle.Connection);
var db = conn.database('document_composer');
// Create a document
app.post('/documents', function(req, res) {
console.log(req.headers['content-type']);
console.log(req.body);
res.send('test');
});
app.configure(function(){
app.use(express.methodOverride());
app.use(express.bodyDecoder());
app.use(app.router);
app.use(express.staticProvider(__dirname));
});
app.listen(3003);
// Output
application/x-www-form-urlencoded
undefined
@tj
Copy link

tj commented Nov 1, 2010

app.post() (or the others) will cause the app.router middleware to be mounted. this allows for small sites to omit app.use(app.router), but in your case here you want app.configure() above your route

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