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

ExceptionHandler for send requests and proxy responses in HttpProxy/ReverseProxy #114

Open
fbuetler opened this issue Feb 25, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@fbuetler
Copy link

Describe the feature

In case any interceptor fails with an exception, it is handled as a 502.

We propose to introduce an exceptionHandler in the HttpProxy to customize this behavior, analogously it is done in the HttpServerRequest, HttpServerResponse and many others.

Relevant code:

    proxy.sendRequest()
      .recover(throwable -> {
        log.trace("Error in sending the request", throwable);
        return Future.succeededFuture(proxyRequest.release().response().setStatusCode(502));
      })
      .compose(proxy::sendProxyResponse)
      .recover(throwable -> {
        log.trace("Error in sending the response", throwable);
        return proxy.response().release().setStatusCode(502).send();
      });

(Source: https://github.com/eclipse-vertx/vertx-http-proxy/blob/4.5.13/src/main/java/io/vertx/httpproxy/impl/ReverseProxy.java#L78-L87)

Use cases

When applying interceptors, the proxy may want to return status codes that differ to the hard-coded 502.

Contribution

I volunteer to implement this feature.

We propose to add the following methods to HttpProxy and ReverseProxy:

  HttpProxy requestExceptionHandler(Handler<Throwable> handler);
  HttpProxy responseExceptionHandler(Handler<Throwable> handler);

Alternatively, only exceptionHandler may be added that is to be used on both request and responses.

@fbuetler fbuetler added the enhancement New feature or request label Feb 25, 2025
@vietj
Copy link
Member

vietj commented Feb 26, 2025

Ok I see, the default exception handler would take care of send 502 ?

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