-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathClient.java
More file actions
38 lines (31 loc) · 1.08 KB
/
Client.java
File metadata and controls
38 lines (31 loc) · 1.08 KB
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
38
package io.vertx.example.webclient.https;
import io.vertx.core.Future;
import io.vertx.core.VerticleBase;
import io.vertx.core.net.JksOptions;
import io.vertx.ext.web.client.WebClient;
import io.vertx.ext.web.client.WebClientOptions;
import io.vertx.launcher.application.VertxApplication;
/*
* @author <a href="mailto:julien@julienviet.com">Julien Viet</a>
*/
public class Client extends VerticleBase {
public static void main(String[] args) {
VertxApplication.main(new String[]{Client.class.getName()});
}
private WebClient client;
@Override
public Future<?> start() throws Exception {
// Create the web client and enable SSL/TLS with a trust store
client = WebClient.create(vertx,
new WebClientOptions()
.setSsl(true)
.setTrustOptions(new JksOptions()
.setPath("io/vertx/example/webclient/https/client-truststore.jks")
.setPassword("wibble")
)
);
return client.get(8443, "localhost", "/")
.send()
.onSuccess(response -> System.out.println("Got HTTP response with status " + response.statusCode()));
}
}