accept optional function to use next

This commit is contained in:
AJ ONeal 2016-08-10 22:23:31 -06:00
förälder d9ff6bf4de
incheckning 1179dff734
1 ändrade filer med 10 tillägg och 2 borttagningar

Visa fil

@ -17,13 +17,21 @@ module.exports.create = function (le) {
}
log(le.debug, "created middleware");
return function () {
return function (_app) {
if (_app && 'function' !== typeof _app) {
throw new Error("use le.middleware() or le.middleware(function (req, res) {})");
}
var prefix = le.acmeChallengePrefix || '/.well-known/acme-challenge/';
return function (req, res, next) {
if (0 !== req.url.indexOf(prefix)) {
log(le.debug, "no match, skipping middleware");
next();
if (_app) {
_app(req, res, next);
}
else {
next();
}
return;
}