Add --read-only option

This commit is contained in:
Typicode
2016-01-07 04:12:04 +01:00
parent d1205844c0
commit 672393e915
5 changed files with 37 additions and 14 deletions

View File

@ -47,5 +47,16 @@ module.exports = function (opts) {
next()
})
// Read-only
if (opts.readOnly) {
arr.push(function (req, res, next) {
if (req.method === 'GET') {
next() // Continue
} else {
res.sendStatus(403) // Forbidden
}
})
}
return arr
}