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

originRequestProvider should be able to access ProxyContext to perform routing based on modified request #44

Open
ThorodanBrom opened this issue Jan 27, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@ThorodanBrom
Copy link

Version

Since originRequestProvider runs after pre-request interceptors, there is no way to pass the ProxyContext to perform routing on the based on the modified request. originRequestProvider only has context of the original request in HttpServerRequest

Context

It would be useful if originRequestProvider could perform routing based on what is present in ProxyContext and ProxyRequest. This may also solve #35 - variables can be set in the ProxyContext to perform routing.

The drawback here would be that originRequestProvider must come in between pre-request and post-request interceptors.

@ThorodanBrom ThorodanBrom added the enhancement New feature or request label Jan 27, 2023
@ThorodanBrom
Copy link
Author

ThorodanBrom commented Jan 27, 2023

One way to solve this would be if we could mention which version of the request should be passed here, the proxied request or the modifies request, when resolving the origin:

Future<HttpClientRequest> f = resolveOrigin(proxyRequest.proxiedRequest());

@chevaris
Copy link

chevaris commented Dec 13, 2023

I had the same need: sharing information between interceptors and originSelector function to perform needed routing.

One option that could be interesting is that originSelector accepts Function<ProxyContext, Future> selector). It is possible to get the original request via context.request().proxiedRequest(). This way it is possible to pass information using ProxyConext get/set methods

As a workaround it is possible to use request headers map of the proxiedRequests to pass Strings between interceptors and originSelector (But it is far from clean solution).

The other option is obviously to write the proxy handler and not using interceptors/originin selectors and do everything in the handler. Probably this was not the original idea of the API

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

No branches or pull requests

2 participants