2020-12-22 17:19:26 -08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
exports = module.exports = {
|
|
|
|
|
get
|
|
|
|
|
};
|
|
|
|
|
|
2021-01-28 13:27:50 -08:00
|
|
|
const HttpError = require('connect-lastmile').HttpError,
|
|
|
|
|
wellknown = require('../wellknown.js');
|
2020-12-22 17:19:26 -08:00
|
|
|
|
|
|
|
|
function get(req, res, next) {
|
|
|
|
|
const host = req.headers['host'];
|
2021-01-28 13:27:50 -08:00
|
|
|
const location = req.params[0];
|
2020-12-22 17:19:26 -08:00
|
|
|
|
2021-01-28 13:27:50 -08:00
|
|
|
wellknown.get(host, location, function (error, result) {
|
2020-12-22 17:19:26 -08:00
|
|
|
if (error) return next(new HttpError(404, error.message));
|
|
|
|
|
|
2021-01-28 13:27:50 -08:00
|
|
|
res.status(200).set('content-type', result.type).send(result.body);
|
2020-12-22 17:19:26 -08:00
|
|
|
});
|
|
|
|
|
}
|