You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
570 B
JavaScript
23 lines
570 B
JavaScript
|
5 years ago
|
'use strict';
|
||
|
|
|
||
|
|
function defaultSkipFilter(/* res */) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
function maybeSkipToNextHandler(container) {
|
||
|
|
var resolverFn = container.options.skipToNextHandlerFilter || defaultSkipFilter;
|
||
|
|
|
||
|
|
return Promise
|
||
|
|
.resolve(resolverFn(container.proxy.res))
|
||
|
|
.then(function (shouldSkipToNext) {
|
||
|
|
if (shouldSkipToNext) {
|
||
|
|
container.user.res.expressHttpProxy = container.proxy;
|
||
|
|
return Promise.reject(container.user.next());
|
||
|
|
} else {
|
||
|
|
return Promise.resolve(container);
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
module.exports = maybeSkipToNextHandler;
|