use of io.vertx.core.http.HttpServer in project vertx-examples by vert-x3.
the class Server method start.
@Override
public void start() throws Exception {
HttpServer server = vertx.createHttpServer(new HttpServerOptions().setUseAlpn(true).setSsl(true).setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("server-key.pem").setCertPath("server-cert.pem")));
server.requestHandler(req -> {
req.response().putHeader("content-type", "text/html").end("<html><body>" + "<h1>Hello from vert.x!</h1>" + "<p>version = " + req.version() + "</p>" + "</body></html>");
}).listen(8443);
}
use of io.vertx.core.http.HttpServer in project vertx-examples by vert-x3.
the class Server method start.
@Override
public void start(Future<Void> startFuture) throws Exception {
HttpServer server = vertx.createHttpServer(new HttpServerOptions().setUseAlpn(true).setKeyCertOptions(new JksOptions().setPath("io/vertx/example/java9/server-keystore.jks").setPassword("wibble")).setSsl(true));
server.requestHandler(req -> {
req.response().end("Hello " + req.version());
}).listen(8080, ar -> startFuture.handle(ar.mapEmpty()));
}
use of io.vertx.core.http.HttpServer in project vertx-examples by vert-x3.
the class Server method start.
@Override
public void start() throws Exception {
HttpServer server = vertx.createHttpServer(new HttpServerOptions().setSsl(true).setKeyStoreOptions(new JksOptions().setPath("server-keystore.jks").setPassword("wibble")));
server.requestHandler(req -> {
req.response().putHeader("content-type", "text/html").end("<html><body><h1>Hello from vert.x!</h1></body></html>");
}).listen(4443);
}
use of io.vertx.core.http.HttpServer in project vertx-examples by vert-x3.
the class ParameterizedTest method test.
@Test
public void test(TestContext context) {
HttpServer server = vertx.createHttpServer().requestHandler(req -> {
context.assertEquals(port, req.localAddress().port());
req.response().end();
});
server.listen(port, "localhost", context.asyncAssertSuccess(s -> {
HttpClient client = vertx.createHttpClient();
Async async = context.async();
HttpClientRequest req = client.get(port, "localhost", "/", resp -> {
context.assertEquals(200, resp.statusCode());
async.complete();
});
req.exceptionHandler(context::fail);
req.end();
}));
}
use of io.vertx.core.http.HttpServer in project incubator-servicecomb-java-chassis by apache.
the class MockForRestServerVerticle method mockRestServerVerticle.
public void mockRestServerVerticle() {
final HttpServer server = Mockito.mock(HttpServer.class);
new MockUp<RestServerVerticle>() {
@Mock
private void startListen(HttpServer server, IpPort ipPort, Future<Void> startFuture) {
}
@Mock
private HttpServer createHttpServer(boolean isHttp_2) {
return server;
}
};
}
Aggregations