Skip to content

Commit

Permalink
[#361] Fix skipToNextHandler, add expressHttpProxy value to user res …
Browse files Browse the repository at this point in the history
…for additional processing. (#373)
  • Loading branch information
monkpow committed Sep 19, 2018
1 parent 762b16f commit 8bac3fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/steps/maybeSkipToNextHandler.js
Expand Up @@ -9,10 +9,14 @@ function maybeSkipToNextHandler(container) {

return Promise
.resolve(resolverFn(container.proxy.res))
.then(function(shouldSkipToNext) {
return (shouldSkipToNext) ? container.user.next() : Promise.resolve(container);
.then(function (shouldSkipToNext) {
if (shouldSkipToNext) {
container.user.res.expressHttpProxy = container.proxy;
return Promise.reject(container.user.next());
} else {
return Promise.resolve(container);
}
})
.catch(Promise.reject);
}

module.exports = maybeSkipToNextHandler;
5 changes: 5 additions & 0 deletions test/maybeSkipToNextHandler.js
Expand Up @@ -3,6 +3,8 @@
var express = require('express');
var request = require('supertest');
var proxy = require('../');
var http = require('http');
var assert = require('assert');

describe('when skipToNextHandlerFilter is defined', function () {

Expand Down Expand Up @@ -39,6 +41,9 @@ describe('when skipToNextHandlerFilter is defined', function () {
}));

app.use(function (req, res) {
assert(res.expressHttpProxy instanceof Object);
assert(res.expressHttpProxy.res instanceof http.IncomingMessage);
assert(res.expressHttpProxy.req instanceof Object);
res.sendStatus(200);
});

Expand Down

0 comments on commit 8bac3fe

Please sign in to comment.