I have a pretty simple RESTful API, and my Express application is configured like this:
app.configure(function () {
app.use(express.static(__dirname + '/public'));
app.use(express.logger('dev'));
app.use(express.bodyParser());
});
app.post('/api/vehicles', vehicles.addVehicle);
How / where can I add middleware that does not allow the request to reach mine app.postand app.getif the content type is not application/json?
Middleware should only stop the request with the wrong content type for the URL starting with /api/.
source
share