-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathServer.java
More file actions
35 lines (29 loc) · 960 Bytes
/
Server.java
File metadata and controls
35 lines (29 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package io.vertx.example.jpms.http2;
import io.vertx.core.*;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.core.json.JsonObject;
import io.vertx.core.net.JksOptions;
public class Server extends VerticleBase {
public static void main(String[] args) {
Vertx vertx = Vertx.vertx();
vertx.deployVerticle(new Server())
.onFailure(Throwable::printStackTrace);
}
@Override
public Future<?> start() {
HttpServerOptions options = new HttpServerOptions()
.setUseAlpn(true)
.setKeyCertOptions(new JksOptions().setPath("server-keystore.jks").setPassword("wibble"))
.setSsl(true);
HttpServer server = vertx
.createHttpServer(options)
.requestHandler(req -> {
req.response().end(new JsonObject()
.put("http", req.version())
.put("message", "Hello World")
.toString());
});
return server.listen(8443);
}
}