-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Server.java
executable file
·37 lines (31 loc) · 1.09 KB
/
Server.java
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
36
37
package io.vertx.example.core.http2.simple;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Launcher;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.core.net.PemKeyCertOptions;
/*
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public class Server extends AbstractVerticle {
public static void main(String[] args) {
Launcher.executeCommand("run", Server.class.getName());
}
@Override
public void start() throws Exception {
HttpServer server =
vertx.createHttpServer(new HttpServerOptions()
.setUseAlpn(true)
.setSsl(true)
.setPemKeyCertOptions(new PemKeyCertOptions()
.setKeyPath("io/vertx/example/core/http2/simple/server-key.pem")
.setCertPath("io/vertx/example/core/http2/simple/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);
}
}