accept optional function to use next
This commit is contained in:
parent
d9ff6bf4de
commit
1179dff734
|
@ -17,13 +17,21 @@ module.exports.create = function (le) {
|
||||||
}
|
}
|
||||||
|
|
||||||
log(le.debug, "created middleware");
|
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/';
|
var prefix = le.acmeChallengePrefix || '/.well-known/acme-challenge/';
|
||||||
|
|
||||||
return function (req, res, next) {
|
return function (req, res, next) {
|
||||||
if (0 !== req.url.indexOf(prefix)) {
|
if (0 !== req.url.indexOf(prefix)) {
|
||||||
log(le.debug, "no match, skipping middleware");
|
log(le.debug, "no match, skipping middleware");
|
||||||
|
if (_app) {
|
||||||
|
_app(req, res, next);
|
||||||
|
}
|
||||||
|
else {
|
||||||
next();
|
next();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue