Files
dougal-software/lib/www/server/api/middleware/event/sequence/get/index.js

32 lines
744 B
JavaScript
Raw Normal View History

const json = require('./json');
const geojson = require('./geojson');
const seis = require('./seis');
const html = require('./html');
2023-09-13 21:58:06 +02:00
const csv = require('./csv');
2021-05-13 20:17:39 +02:00
const pdf = require('./pdf');
module.exports = async function (req, res, next) {
try {
const handlers = {
"application/json": json,
"application/geo+json": geojson,
"application/vnd.seis+json": seis,
"text/html": html,
2023-09-13 21:58:06 +02:00
"text/csv": csv,
2021-05-13 20:17:39 +02:00
"application/pdf": pdf
};
const mimetype = (handlers[req.query.mime] && req.query.mime) || req.accepts(Object.keys(handlers));
if (mimetype) {
res.set("Content-Type", mimetype);
await handlers[mimetype](req, res, next);
} else {
res.status(406).send();
next();
}
} catch (err) {
next(err);
}
}