Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FeatureReqeust: Pass the control back to the express server upon success #361

Closed
neon-vortex opened this issue Aug 31, 2018 · 3 comments
Closed

Comments

@neon-vortex
Copy link

When express-http-proxy is used as a middleware and we would like to know certain metrics such as timeTakenForResponse, we would need to be able to pass control back to the express server.

  • Traditionally this is done by calling 'next()' to return control.
@neon-vortex neon-vortex reopened this Aug 31, 2018
neon-vortex pushed a commit to neon-vortex/express-http-proxy that referenced this issue Aug 31, 2018
@neon-vortex neon-vortex changed the title FeatureReqeust: Pass the control back to the express server upon success/failure FeatureReqeust: Pass the control back to the express server upon success Aug 31, 2018
@mx781
Copy link

mx781 commented Sep 5, 2018

It does seem you can do this by changing skipToNextHandlerFilter to return true, but it seems to me that the proxy reponse is no longer available at that point. @monkpow what is the intention in this case - what might be worth a PR?

Edit: My bad, it seems we are able to do this. @siva-vadivel , have a look at userResDecorator - that gets executed right before sending so should suit your use case as well?

@neon-vortex
Copy link
Author

userResDecorator is executed right before sending the response to the user, however we would like to pass control bask to express after sending the response. One suggestion would be to call the express's next() method inside userResDecorator, but once next() is called, we would not be able to know when the response was completed (especially in the case of streaming responses)

monkpow added a commit that referenced this issue Sep 19, 2018
@monkpow
Copy link
Collaborator

monkpow commented Sep 19, 2018

Ok, @siva-vadivel and @mx781, thanks for raising the issue, and the discussion.

See commit above; I fixed the skipToNextHandler, and added the expressHttpProxy res and req to the user.res so you can read the proxy res and req values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants