1919import io .vertx .core .eventbus .EventBus ;
2020import io .vertx .core .file .FileSystem ;
2121import io .vertx .core .http .*;
22+ import io .vertx .core .http .impl .HttpServerBuilderImpl ;
2223import io .vertx .core .impl .VertxImpl ;
2324import io .vertx .core .internal .ContextInternal ;
2425import io .vertx .core .dns .impl .DnsAddressResolverProvider ;
3435import io .vertx .core .net .QuicClientConfig ;
3536import io .vertx .core .net .QuicServer ;
3637import io .vertx .core .net .QuicServerConfig ;
38+ import io .vertx .core .net .SSLEngineOptions ;
3739import io .vertx .core .net .ServerSSLOptions ;
3840import io .vertx .core .net .TcpClientConfig ;
3941import io .vertx .core .net .TcpServerConfig ;
@@ -324,7 +326,25 @@ default QuicClient createQuicClient(QuicClientConfig config) {
324326 * @param options the options to use
325327 * @return the server
326328 */
327- HttpServer createHttpServer (HttpServerOptions options );
329+ default HttpServer createHttpServer (HttpServerOptions options ) {
330+ HttpServerConfig config = new HttpServerConfig (options );
331+ ServerSSLOptions sslOptions = options .getSslOptions ();
332+ if (sslOptions != null ) {
333+ sslOptions = sslOptions .copy ();
334+ } else if (options .isSsl ()) {
335+ sslOptions = new ServerSSLOptions ();
336+ }
337+ SSLEngineOptions sslEngineOptions = options .getSslEngineOptions ();
338+ if (sslEngineOptions != null ) {
339+ sslEngineOptions = sslEngineOptions .copy ();
340+ }
341+ HttpServerBuilder builder = ((HttpServerBuilderImpl )httpServerBuilder ())
342+ .with (config )
343+ .with (sslOptions )
344+ .with (sslEngineOptions )
345+ .registerWebSocketWriteHandlers (options .isRegisterWebSocketWriteHandlers ());
346+ return builder .build ();
347+ }
328348
329349 /**
330350 * Create an HTTP server using the specified config
@@ -342,7 +362,9 @@ default HttpServer createHttpServer(HttpServerConfig config) {
342362 * @param config the config to use
343363 * @return the server
344364 */
345- HttpServer createHttpServer (HttpServerConfig config , ServerSSLOptions sslOptions );
365+ default HttpServer createHttpServer (HttpServerConfig config , ServerSSLOptions sslOptions ) {
366+ return httpServerBuilder ().with (config ).with (sslOptions ).build ();
367+ }
346368
347369 /**
348370 * Create an HTTP/HTTPS server using default options
@@ -353,6 +375,14 @@ default HttpServer createHttpServer() {
353375 return createHttpServer (new HttpServerOptions ());
354376 }
355377
378+ /**
379+ * Provide a builder for {@link HttpServer}, it can be used to configure advanced
380+ * HTTP servre settings like a connection handler.
381+ * <p>
382+ * Example usage: {@code HttpServer server = vertx.httpServerBuilder().with(options).withConnectHandler(conn -> ...).build()}
383+ */
384+ HttpServerBuilder httpServerBuilder ();
385+
356386 /**
357387 * Create a WebSocket client using default options
358388 *
0 commit comments