0.1.0 • Published 10 years ago

express-accepts v0.1.0

Weekly downloads
20
License
-
Repository
-
Last release
10 years ago

accepts

Express middleware to help you manage the HTTP Accept header.

Basic usage:

var app = express();
app.get('/api', accepts('application/json'), function(req, res) {
	// Only if Accept: application/json is true
	return res.status(200).send({ hello: 'world' });
});

Use fancier routing:

var app = express();
app.get('/', accepts('text/html', 'application/json'));
app.get('/', accepts.on('text/html'), function(req, res) {
	return res.status(200).render('index');
});
app.get('/', accepts.on('application/json'), function(req, res) {
	return res.status(200).send({ hello: 'world' });
});