Files
dougal-software/lib/www/server/api/middleware/sequence/get/index.js
D. Berge 808c9987af Add binary format middleware for sequence data.
It responds to the MIME type:
application/dougal-map-sequence+octet-stream
2025-07-26 19:05:00 +02:00

26 lines
608 B
JavaScript

const json = require('./json');
const geojson = require('./geojson');
const binary = require('./binary');
module.exports = async function (req, res, next) {
try {
const handlers = {
"application/json": json,
"application/geo+json": geojson,
"application/dougal-map-sequence+octet-stream": binary
};
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);
}
}