Merge branch 'master' of github.com:Daplie/walnut
This commit is contained in:
commit
e28d05aa6c
|
@ -89,13 +89,19 @@ function loadPages(pkgConf, packagedPage, req, res, next) {
|
||||||
if (!packagedPage._promise_page) {
|
if (!packagedPage._promise_page) {
|
||||||
packagedPage._promise_page = new PromiseA(function (resolve, reject) {
|
packagedPage._promise_page = new PromiseA(function (resolve, reject) {
|
||||||
fs.exists(pkgpath, function (exists) {
|
fs.exists(pkgpath, function (exists) {
|
||||||
|
var staticServer;
|
||||||
|
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
reject(new Error("package '" + pkgpath + "' is registered but does not exist"));
|
reject(new Error("package '" + pkgpath + "' is registered but does not exist"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.log('[static mount]', pkgpath);
|
//console.log('[static mount]', pkgpath);
|
||||||
resolve(require('serve-static')(pkgpath));
|
// https://github.com/expressjs/serve-static/issues/54
|
||||||
|
// https://github.com/pillarjs/send/issues/91
|
||||||
|
// https://example.com/.well-known/acme-challenge/xxxxxxxxxxxxxxx
|
||||||
|
staticServer = require('serve-static')(pkgpath, { dotfiles: undefined });
|
||||||
|
resolve(staticServer);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -411,10 +417,27 @@ function mapToApp(opts, req, res, next) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO .well-known can be an API (webfinger, letsencrypt, oauth3)
|
||||||
|
// or static (...???)
|
||||||
|
|
||||||
if (!router._re_api.test(req.url)) {
|
if (!router._re_api.test(req.url)) {
|
||||||
//console.log('[static router]');
|
//console.log('[static router]');
|
||||||
//console.log(router._re_api, req.url);
|
//console.log(router._re_api, req.url);
|
||||||
layerItUp(pkgConf, router, req, res, next);
|
layerItUp(pkgConf, router, req, res, function (err) {
|
||||||
|
if (err) {
|
||||||
|
next(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/\/\.well-known([\/?]|$)/.test(req.url)) {
|
||||||
|
console.log('[TODO] handle .well-known as API');
|
||||||
|
// rewrite api as /api/org.ietf/.well-known ?
|
||||||
|
// pass through simply as /.well-known ?
|
||||||
|
// runApi(opts, router, req, res, next)
|
||||||
|
}
|
||||||
|
|
||||||
|
next();
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue