Hello all,
I would need your help on the following.
I am trying to implement a HTTP proxy using vert.x reverse proxy to capture the incoming request and outgoing response.
But for the response I am not able to capture it as a plain text whereas for the request I use interceptor that intercepts the request and logs the request as plain text.
How can capture the response as a plain text.
This is my code
public Future<Runnable> start(Vertx vertx) {
HttpClient proxyClient = vertx.createHttpClient();
HttpProxy proxy = HttpProxy.reverseProxy(proxyClient);
proxy.origin(targetPort, targetHost);
proxy.addInterceptor(new ProxyInterceptor() {
@Override
public Future<ProxyResponse> handleProxyRequest(ProxyContext context) {
ProxyRequest proxyRequest = context.request();
HttpServerRequest originalRequest = proxyRequest.proxiedRequest();
originalRequest.bodyHandler(requestBody -> {
LOG.info("Request Body: {}", requestBody.toString("UTF-8"));
});
// Continue the interception chain
return context.sendRequest();
}
});
proxy.addInterceptor(new ProxyInterceptor() {
@Override
public Future<Void> handleProxyResponse(ProxyContext context) {
ProxyResponse proxyResponse = context.response();
// there is no proxyResponse.proxiedResponse() method and no handlers for ProxyResponse either
return context.response().send();
}
});
HttpServer proxyServer = vertx.createHttpServer();
proxyServer.requestHandler(proxy).listen(listeningPort);
}
Please help
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/7abaf3e2-dc31-4444-8810-4f6760b95b09n%40googlegroups.com.