1515import io .vertx .core .Future ;
1616
1717import java .util .concurrent .TimeUnit ;
18+ import java .util .function .Function ;
1819
1920/**
2021 * The API to interacts with an HTTP server.
@@ -41,6 +42,10 @@ default Future<HttpClientRequest> request() {
4142 */
4243 Future <HttpClientRequest > request (RequestOptions options );
4344
45+ default <T > Future <T > request (RequestOptions options , Function <HttpClientRequest , Future <T >> handler ) {
46+ return request (options ).compose (handler );
47+ }
48+
4449 /**
4550 * Create an HTTP request to send to the server at the {@code host} and {@code port}.
4651 *
@@ -54,6 +59,10 @@ default Future<HttpClientRequest> request(HttpMethod method, int port, String ho
5459 return request (new RequestOptions ().setMethod (method ).setPort (port ).setHost (host ).setURI (requestURI ));
5560 }
5661
62+ default <T > Future <T > request (HttpMethod method , int port , String host , String requestURI , Function <HttpClientRequest , Future <T >> handler ) {
63+ return request (method , port , host , requestURI ).compose (handler );
64+ }
65+
5766 /**
5867 * Create an HTTP request to send to the server at the {@code host} and default port.
5968 *
@@ -66,6 +75,10 @@ default Future<HttpClientRequest> request(HttpMethod method, String host, String
6675 return request (new RequestOptions ().setMethod (method ).setHost (host ).setURI (requestURI ));
6776 }
6877
78+ default <T > Future <T > request (HttpMethod method , String host , String requestURI , Function <HttpClientRequest , Future <T >> handler ) {
79+ return request (method , host , requestURI ).compose (handler );
80+ }
81+
6982 /**
7083 * Create an HTTP request to send to the server at the default host and port.
7184 *
@@ -77,6 +90,10 @@ default Future<HttpClientRequest> request(HttpMethod method, String requestURI)
7790 return request (new RequestOptions ().setMethod (method ).setURI (requestURI ));
7891 }
7992
93+ default <T > Future <T > request (HttpMethod method , String requestURI , Function <HttpClientRequest , Future <T >> handler ) {
94+ return request (method , requestURI ).compose (handler );
95+ }
96+
8097 /**
8198 * Shutdown with a 30 seconds timeout ({@code shutdown(30, TimeUnit.SECONDS)}).
8299 *
0 commit comments