1919import io .vertx .core .net .SSLOptions ;
2020
2121import java .util .concurrent .TimeUnit ;
22+ import java .util .function .Function ;
2223
2324/**
2425 * An asynchronous HTTP client.
@@ -59,6 +60,10 @@ public interface HttpClient extends io.vertx.core.metrics.Measured {
5960 */
6061 Future <HttpClientRequest > request (RequestOptions options );
6162
63+ default <T > Future <T > request (RequestOptions options , Function <HttpClientRequest , Future <T >> handler ) {
64+ return request (options ).compose (handler );
65+ }
66+
6267 /**
6368 * Create an HTTP request to send to the server at the {@code host} and {@code port}.
6469 *
@@ -72,6 +77,10 @@ default Future<HttpClientRequest> request(HttpMethod method, int port, String ho
7277 return request (new RequestOptions ().setMethod (method ).setPort (port ).setHost (host ).setURI (requestURI ));
7378 }
7479
80+ default <T > Future <T > request (HttpMethod method , int port , String host , String requestURI , Function <HttpClientRequest , Future <T >> handler ) {
81+ return request (method , port , host , requestURI ).compose (handler );
82+ }
83+
7584 /**
7685 * Create an HTTP request to send to the server at the {@code host} and default port.
7786 *
@@ -84,6 +93,10 @@ default Future<HttpClientRequest> request(HttpMethod method, String host, String
8493 return request (new RequestOptions ().setMethod (method ).setHost (host ).setURI (requestURI ));
8594 }
8695
96+ default <T > Future <T > request (HttpMethod method , String host , String requestURI , Function <HttpClientRequest , Future <T >> handler ) {
97+ return request (method , host , requestURI ).compose (handler );
98+ }
99+
87100 /**
88101 * Create an HTTP request to send to the server at the default host and port.
89102 *
@@ -95,6 +108,10 @@ default Future<HttpClientRequest> request(HttpMethod method, String requestURI)
95108 return request (new RequestOptions ().setMethod (method ).setURI (requestURI ));
96109 }
97110
111+ default <T > Future <T > request (HttpMethod method , String requestURI , Function <HttpClientRequest , Future <T >> handler ) {
112+ return request (method , requestURI ).compose (handler );
113+ }
114+
98115 /**
99116 * Close the client immediately ({@code close(0, TimeUnit.SECONDS}).
100117 *
0 commit comments