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

Async getHost support, Node 12 deprecation fix #420

Closed
wants to merge 7 commits into from

Conversation

bconnorwhite
Copy link

@bconnorwhite bconnorwhite commented Sep 1, 2019

Asynchronous "getHost" implementation:
Issue #284

OutgoingMessage.prototype._headers is deprecated in Node.js 12:
Issue #413

@bconnorwhite bconnorwhite changed the title OutgoingMessage.prototype._headers is deprecated in Node.js 12 Async getHost support, OutgoingMessage.prototype._headers is deprecated in Node.js 12 Sep 1, 2019
@bconnorwhite bconnorwhite changed the title Async getHost support, OutgoingMessage.prototype._headers is deprecated in Node.js 12 Async getHost support, Node 12 deprecation fix Sep 1, 2019
container.proxy.reqBuilder.port = container.options.port || parsedHost.port;
container.proxy.requestModule = parsedHost.module;
return Promise.resolve(container);
return Promise.resolve(parsedHost).then((parsedHost) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for using a promise here for consistency

@monkpow
Copy link
Collaborator

monkpow commented Sep 24, 2019

Hey @connorwhite,

Thank you for this. I would accept everything excluding the asynchronous host immediately, but I'd like to discuss that part.

Historically, this library has held that dynamic host resolution is best handled by the main application, but I'm always interested in discussing this.

Can you tell me about the use case that you are solving for?

@bconnorwhite
Copy link
Author

bconnorwhite commented Sep 24, 2019

@monkpow, example use case for asynchronous host would be authenticating a user, and then using different host based on the result, ex: different host for different user roles.

Mostly though it just seemed odd to me that most of the other functions support promises but not the host. Is there a reason dynamic host resolution is different from dynamic path resolution (proxyReqPathResolver)?

Currently, since proxyReqPathResolver supports promises you could put these at different paths (ex: /endpoint/role1 and /endpoint/role2). Asynchronous host resolution would be nice as it would allow you to also route to different hosts (ex: localhost:4000/endpoint and localhost:4010/endpoint).

Also it seems like others have interest in this:
https://github.com/villadora/express-http-proxy/issues?utf8=%E2%9C%93&q=getHost

@monkpow
Copy link
Collaborator

monkpow commented Sep 25, 2019

@connorwhite

Right on.

  1. My strong opinion is this kind of case is best handled by the wrapping application; however:
  2. Several folks have requested this feature, and I did say I'd accept it with Promises on prior review, so I'll accept it.

I picked several of your commits to master already (related to Node 12 deprecation). I'd like to put this async host on on a separate release. Give me a couple days and I'll come back for the aysnc host commits.

@monkpow
Copy link
Collaborator

monkpow commented Sep 25, 2019

@connorwhite Ok, so I'm closing this one, and opened a new PR over here #433 with just the async host stuff. Thanks again.

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

Successfully merging this pull request may close these issues.

2 participants