|
|
@ -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; |
|
|
|
} |
|
|
|
|
|
|
|