@@ -90,9 +90,7 @@ public static int listen(HttpEndpointRequestHandler requestHandler) {
9090
9191 /** Like {@link #listen(Endpoint, int)}, with an already built request handler */
9292 public static int listen (HttpEndpointRequestHandler requestHandler , int port ) {
93- HttpServer server = Vertx .vertx ().createHttpServer (DEFAULT_OPTIONS );
94- server .requestHandler (requestHandler );
95- return handleStart (server .listen (port ));
93+ return handleStart (fromHandler (requestHandler ).listen (port ));
9694 }
9795
9896 /** Create a Vert.x {@link HttpServer} from the provided endpoint. */
@@ -134,9 +132,7 @@ public static HttpServer fromEndpoint(Vertx vertx, Endpoint.Builder endpointBuil
134132 * HttpServerOptions}.
135133 */
136134 public static HttpServer fromEndpoint (Vertx vertx , Endpoint endpoint , HttpServerOptions options ) {
137- HttpServer server = vertx .createHttpServer (options );
138- server .requestHandler (HttpEndpointRequestHandler .fromEndpoint (endpoint ));
139- return server ;
135+ return fromHandler (vertx , HttpEndpointRequestHandler .fromEndpoint (endpoint ), options );
140136 }
141137
142138 /** Like {@link #fromEndpoint(Vertx, Endpoint, HttpServerOptions)} */
@@ -145,6 +141,36 @@ public static HttpServer fromEndpoint(
145141 return fromEndpoint (vertx , endpointBuilder .build (), options );
146142 }
147143
144+ /** Create a Vert.x {@link HttpServer} from the provided {@link HttpEndpointRequestHandler}. */
145+ public static HttpServer fromHandler (HttpEndpointRequestHandler handler ) {
146+ return fromHandler (handler , DEFAULT_OPTIONS );
147+ }
148+
149+ /**
150+ * Create a Vert.x {@link HttpServer} from the provided {@link HttpEndpointRequestHandler}, with
151+ * the given {@link HttpServerOptions}.
152+ */
153+ public static HttpServer fromHandler (
154+ HttpEndpointRequestHandler handler , HttpServerOptions options ) {
155+ return fromHandler (Vertx .vertx (), handler , options );
156+ }
157+
158+ /** Create a Vert.x {@link HttpServer} from the provided {@link HttpEndpointRequestHandler}. */
159+ public static HttpServer fromHandler (Vertx vertx , HttpEndpointRequestHandler handler ) {
160+ return fromHandler (vertx , handler , DEFAULT_OPTIONS );
161+ }
162+
163+ /**
164+ * Create a Vert.x {@link HttpServer} from the provided {@link HttpEndpointRequestHandler}, with
165+ * the given {@link HttpServerOptions}.
166+ */
167+ public static HttpServer fromHandler (
168+ Vertx vertx , HttpEndpointRequestHandler handler , HttpServerOptions options ) {
169+ HttpServer server = vertx .createHttpServer (options );
170+ server .requestHandler (handler );
171+ return server ;
172+ }
173+
148174 private static int handleStart (Future <HttpServer > fut ) {
149175 try {
150176 HttpServer server = fut .toCompletionStage ().toCompletableFuture ().join ();
0 commit comments