mc-core
Version:
Deployments made simple
25 lines (15 loc) • 357 B
JavaScript
module.exports = function(req, res, next) {
res.status(404)
// respond with html page
if (req.accepts('html')) {
res.send('<h1>404 Not found</h1>')
return
}
// respond with json
if (req.accepts('json')) {
res.send({error: 'Not found'})
return
}
// default to plain-text. send()
res.type('txt').send('Not found')
}