@Override public void start() throws Exception { vertx.createHttpServer().requestHandler(req -> req.response().end("Hello World!")).listen(8080); } }
@Override public void start(Future<Void> startFuture) { Router router = Router.router(vertx); router.get("/").handler(this::hello); router.get("/time").handler(this::now); vertx.createHttpServer() .requestHandler(router) .listen(8080, asyncStart -> { if (asyncStart.succeeded()) { startFuture.complete(); logger.info("HTTP server running on port 8080"); } else { logger.error("Woops", asyncStart.cause()); startFuture.fail(asyncStart.cause()); } }); }
public void setUp() throws Exception { super.setUp(); server = vertx.createHttpServer(new HttpServerOptions().setPort(DEFAULT_HTTP_PORT).setHost(DEFAULT_HTTP_HOST)); }
@Test public void testDummyHttpServerMetrics() { HttpServer server = vertx.createHttpServer(new HttpServerOptions()); assertFalse(server.isMetricsEnabled()); }
@Test public void testNoRequestHandler() throws Exception { CountDownLatch latch = new CountDownLatch(1); vertx.createHttpServer() .websocketHandler(ws -> fail()) .listen(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, onSuccess(v -> latch.countDown())); awaitLatch(latch); client.getNow(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/", onSuccess(resp -> { resp.endHandler(v -> { assertEquals(400, resp.statusCode()); testComplete(); }); })); await(); } }
@Test public void testServerLogging() throws Exception { server.close(); server = vertx.createHttpServer(createBaseServerOptions().setLogActivity(true)); TestLoggerFactory factory = testLogging(); if (this instanceof Http1xTest) { assertTrue(factory.hasName("io.netty.handler.logging.LoggingHandler")); } else { assertTrue(factory.hasName("io.netty.handler.codec.http2.Http2FrameLogger")); } }
@Override public void start() throws Exception { vertx.createHttpServer().requestHandler(request -> { request.response().end("Hello Java world !"); }).listen(8080); } }
@Override public void start() { Router router = Router.router(vertx); router.get("/").handler(rc -> rc.response().end(UUID.randomUUID().toString())); vertx.createHttpServer() .requestHandler(router) .listen(8080); } }
public void setUp() throws Exception { super.setUp(); client = vertx.createHttpClient(new HttpClientOptions().setTryUseCompression(true)); clientraw = vertx.createHttpClient(new HttpClientOptions().setTryUseCompression(false)); HttpServerOptions serverOpts = new HttpServerOptions() .setPort(DEFAULT_HTTP_PORT) .setCompressionSupported(true); // server = vertx.createHttpServer(); serverWithMinCompressionLevel = vertx.createHttpServer(serverOpts.setPort(DEFAULT_HTTP_PORT - 1).setCompressionLevel(1)); serverWithMaxCompressionLevel = vertx.createHttpServer(serverOpts.setPort(DEFAULT_HTTP_PORT + 1).setCompressionLevel(9)); }
@Override public void start() { vertx.createHttpServer() .requestHandler(req -> req.response().end("Bonjour")) .listen(8080); }
@Override public void start() throws Exception { Router router = Router.router(vertx); router.route().handler(routingContext -> { routingContext.response().putHeader("content-type", "text/html").end("Hello World!"); }); vertx.createHttpServer().requestHandler(router).listen(8080); } }
@Override public void setUp() throws Exception { super.setUp(); client = vertx.createHttpClient(new HttpClientOptions()); server = vertx.createHttpServer(new HttpServerOptions().setPort(DEFAULT_HTTP_PORT).setHost(DEFAULT_HTTP_HOST).setHandle100ContinueAutomatically(true)); }
@Override public void start() { // Create an HTTP server which simply returns "Hello World!" to each request. vertx.createHttpServer().requestHandler(req -> req.response().end("Hello World!")).listen(8080); } }
@Override public void setUp() throws Exception { super.setUp(); CountDownLatch listenLatch = new CountDownLatch(1); httpServer = vertx.createHttpServer() .requestHandler(request -> {}) .exceptionHandler(t -> { caught.set(t); resetLatch.countDown(); }) .listen(8080, onSuccess(server -> listenLatch.countDown())); awaitLatch(listenLatch); }
@Override public void setUp() throws Exception { super.setUp(); client = vertx.createHttpClient(new HttpClientOptions()); server = vertx.createHttpServer(new HttpServerOptions().setPort(DEFAULT_HTTP_PORT).setHost(DEFAULT_HTTP_HOST).setHandle100ContinueAutomatically(true)); }
@Override public void start() throws Exception { vertx.createHttpServer().requestHandler(request -> { request.response().end("Hello Java world !"); }).listen(8080); } }
@Override public void start() { // Create an HTTP server which simply returns "Hello World!" to each request. vertx.createHttpServer() .requestHandler(req -> req.response().end("Hello World!")) .listen(8080); } }
@Override public void start() throws Exception { vertx.createHttpServer().requestHandler(req -> req.response().end("Hello World!")).listen(8080); }
public static void main(String[] args) { // Create an HTTP server which simply returns "Hello World!" to each request. Vertx.vertx().createHttpServer().requestHandler(req -> req.response().end("Hello World!")).listen(8080); } }
@Override public void start() throws Exception { vertx.createHttpServer().requestHandler(req -> { final String name = ManagementFactory.getRuntimeMXBean().getName(); req.response().end("Happily served by " + name); }).listen(8080); } }