use of io.vertx.core.http.HttpServer in project vertx-openshift-it by cescoffier.
the class SenderVerticle method startHttpServer.
private Future<HttpServer> startHttpServer() {
Future<HttpServer> future = Future.future();
Router router = setupRouter();
vertx.createHttpServer().requestHandler(router::accept).listen(8080, future);
return future;
}
use of io.vertx.core.http.HttpServer in project vertx-openshift-it by cescoffier.
the class EdgeVerticle method start.
@Override
public void start() throws Exception {
client = WebClient.create(vertx, new WebClientOptions().setProtocolVersion(HttpVersion.HTTP_2).setSsl(true).setUseAlpn(true).setTrustAll(true));
Router router = Router.router(vertx);
router.get("/").handler(this::hello);
router.get("/health").handler(rc -> rc.response().end("OK"));
router.get("/aloha").handler(this::front);
router.get("/hello").handler(this::grpc);
HttpServer server = vertx.createHttpServer(new HttpServerOptions());
server.requestHandler(router::accept).listen(8080);
}
use of io.vertx.core.http.HttpServer in project vertx-openshift-it by cescoffier.
the class HelloHttp2Verticle method start.
@Override
public void start() throws Exception {
vertx.exceptionHandler(Throwable::printStackTrace);
HttpServer server = vertx.createHttpServer(new HttpServerOptions().setUseAlpn(true).setSsl(true).setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("server-key.pem").setCertPath("server-cert.pem")));
server.requestHandler(req -> {
System.out.println("Handling request on Aloha " + req.version());
req.response().putHeader("content-type", "text/html").end("<html><body>" + "<h1>Aloha from vert.x!</h1>" + "<p>version = " + req.version() + "</p>" + "</body></html>");
}).listen(8081);
}
use of io.vertx.core.http.HttpServer in project vert.x by eclipse.
the class SimpleServer method start.
@Override
public void start(Promise<Void> startPromise) throws Exception {
HttpServer server = vertx.createHttpServer(new HttpServerOptions().setPort(8080));
server.requestHandler(req -> req.response().end());
server.listen(res -> {
if (res.succeeded()) {
startPromise.complete();
} else {
startPromise.fail(res.cause());
}
});
}
use of io.vertx.core.http.HttpServer in project vert.x by eclipse.
the class HttpConnectionEarlyResetTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
CountDownLatch listenLatch = new CountDownLatch(1);
Context ctx = vertx.getOrCreateContext();
httpServer = vertx.createHttpServer().requestHandler(request -> {
}).exceptionHandler(t -> {
assertSame(ctx, Vertx.currentContext());
caught.set(t);
resetLatch.countDown();
});
ctx.runOnContext(v -> {
httpServer.listen(8080, onSuccess(server -> listenLatch.countDown()));
});
awaitLatch(listenLatch);
}
Aggregations