npm install express-accepts-override
var acceptsOverride = require('express-accepts-override');
app.use(acceptsOverride(options));
accepts: ['json', 'html', 'csv', 'txt'] // must be valid mime extensions query: 'format' // /path?format=csv resolveOrder: ['suffix', 'query', 'header'] // will use first match
resolveOrder options:
- suffix: /somepath.json, /somepath.csv
- query: /somepath?format=json, /somepath?format=csv (change 'format' to something else with options.query)
- header: 'accepts:text/csv'