email autoconfig
This commit is contained in:
@@ -4,18 +4,16 @@ exports = module.exports = {
|
||||
get
|
||||
};
|
||||
|
||||
const domains = require('../domains.js'),
|
||||
HttpError = require('connect-lastmile').HttpError;
|
||||
const HttpError = require('connect-lastmile').HttpError,
|
||||
wellknown = require('../wellknown.js');
|
||||
|
||||
function get(req, res, next) {
|
||||
const host = req.headers['host'];
|
||||
const location = req.params[0];
|
||||
|
||||
domains.get(host, function (error, domain) {
|
||||
wellknown.get(host, location, function (error, result) {
|
||||
if (error) return next(new HttpError(404, error.message));
|
||||
|
||||
const location = req.params[0];
|
||||
if (!domain.wellKnown || !(location in domain.wellKnown)) return next(new HttpError(404, 'No custom well-known config'));
|
||||
|
||||
res.status(200).send(domain.wellKnown[location]);
|
||||
res.status(200).set('content-type', result.type).send(result.body);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user