(req, res, next)
| 1 | import { handlers as debug } from '../debug.mjs' |
| 2 | |
| 3 | export default async function handler (req, res, next) { |
| 4 | debug('DELETE -- Request on' + req.originalUrl) |
| 5 | |
| 6 | const ldp = req.app.locals.ldp |
| 7 | try { |
| 8 | await ldp.delete(req) |
| 9 | debug('DELETE -- Ok.') |
| 10 | res.sendStatus(200) |
| 11 | next() |
| 12 | } catch (err) { |
| 13 | debug('DELETE -- Failed to delete: ' + err) |
| 14 | |
| 15 | // method DELETE not allowed |
| 16 | if (err.status === 405) { |
| 17 | res.set('allow', 'OPTIONS, HEAD, GET, PATCH, POST, PUT') |
| 18 | } |
| 19 | next(err) |
| 20 | } |
| 21 | } |