Skip to content

Instantly share code, notes, and snippets.

@daffl
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save daffl/760e744add03b7ae6303 to your computer and use it in GitHub Desktop.

Select an option

Save daffl/760e744add03b7ae6303 to your computer and use it in GitHub Desktop.
An Epress middleware example
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json())
.use(function(req, res, next) {
// Add the username to the parsed body
// set by bodyParser middleware
req.body.username = 'David';
next();
})
.use(function(req, res) {
res.json(req.body || { message: 'No content' });
});
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment