2021-09-04 18:04:52 +02:00
|
|
|
const json = require('./json');
|
|
|
|
|
const geojson = require('./geojson');
|
2022-03-29 13:24:38 +02:00
|
|
|
const binary = require('./binary');
|
2021-09-04 18:04:52 +02:00
|
|
|
|
|
|
|
|
module.exports = async function (req, res, next) {
|
|
|
|
|
try {
|
|
|
|
|
const handlers = {
|
|
|
|
|
"application/json": json,
|
|
|
|
|
"application/geo+json": geojson,
|
2025-08-03 11:17:31 +02:00
|
|
|
"application/vnd.aaltronav.dougal+octet-stream": binary,
|
|
|
|
|
"application/vnd.aaltronav.dougal+octet-stream; format=0x1c": binary,
|
2021-09-04 18:04:52 +02:00
|
|
|
};
|
2022-04-29 14:48:21 +02:00
|
|
|
|
2021-09-04 18:04:52 +02:00
|
|
|
const mimetype = (handlers[req.query.mime] && req.query.mime) || req.accepts(Object.keys(handlers));
|
2022-04-29 14:48:21 +02:00
|
|
|
|
2021-09-04 18:04:52 +02:00
|
|
|
if (mimetype) {
|
|
|
|
|
res.set("Content-Type", mimetype);
|
|
|
|
|
await handlers[mimetype](req, res, next);
|
|
|
|
|
} else {
|
|
|
|
|
res.status(406).send();
|
|
|
|
|
next();
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
|
|
|
|
next(err);
|
|
|
|
|
}
|
|
|
|
|
}
|