Skip to content

Commit

Permalink
- Fixes HTTP/2 Custom Frames example in vertx-core.
Browse files Browse the repository at this point in the history
- Fixes Net Echo SSL example in vertx-core.
- Fixes HTTP/2 Push example error in vertx-core.
- Fixes HTTP/2 Simple example bug in vertx-core.
- Fixes HTTP HTTPs example bug in vertx-core.
- Addes error handling to the HTTP/2 Custom Frames example in vertx-core.
- Addes main function for HTTP/2 Simple example in vertx-core.
- Removes useless handling for Safari browser for HTTP/2 Push example in vertx-core.
- Removes io.vertx.example.core.net.greeter package which is not described in README.
- Updates all dependencies of example of vertx-core.
- Removes introduction to Groovy verticles.
- Remove useless io.netty:netty-tcnative-boringssl-static .
  • Loading branch information
linghengqian committed Nov 20, 2022
1 parent c264d64 commit 17bb16b
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 198 deletions.
20 changes: 0 additions & 20 deletions core-examples/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -464,26 +464,6 @@ Happily served by [email protected]

The verticle has been migrated.

== Groovy verticles

Vert.x supports several _formats_ to develop verticles in Groovy. This link:src/main/groovy/verticles[directory]
illustrates the different formats:

* link:src/main/groovy/verticles/script.groovy[plain script] - a verticle developed as a plain Groovy script
* link:src/main/groovy/verticles/script-with-hooks.groovy[plain script with hooks] - a verticle developed as a script
with hooks called by vert.x when the verticle is deployed and un-deployed
* link:src/main/groovy/verticles/verticle-extending-abstract-verticle.groovy[class extending AbstractVerticle] - a
verticle developed as a class extending `AbstractVerticle`
* link:src/main/groovy/verticles/verticle-extending-groovy-verticle.groovy[class extending GroovyVerticle] - a
verticle developed as a class extending `GroovyVerticle`

You can run these examples using the `vertx` command line. For example:

[source,shell]
----
vertx run script.groovy
----

== JSON streaming parser

A simple example illustrating how to use the streaming `JsonParser` to parse a giant array of small objects.
Expand Down
13 changes: 3 additions & 10 deletions core-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.vertx</groupId>
<artifactId>core-examples</artifactId>
<version>4.3.1</version>
<version>4.3.5</version>

<dependencies>

Expand All @@ -17,16 +17,9 @@
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.11.3</version>
<artifactId>jackson-databind</artifactId>
<version>2.14.0</version>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>2.0.34.Final</version>
</dependency>

<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-hazelcast</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.net.JksOptions;
import io.vertx.example.util.Runner;

/*
* @author <a href="http://tfox.org">Tim Fox</a>
* @author linghengqian
*/
public class Client extends AbstractVerticle {

Expand All @@ -21,7 +23,9 @@ public void start() throws Exception {

// Note! in real-life you wouldn't often set trust all to true as it could leave you open to man in the middle attacks.

HttpClientOptions options = new HttpClientOptions().setSsl(true).setTrustAll(true);
HttpClientOptions options = new HttpClientOptions().setSsl(true).setTrustAll(true).setKeyStoreOptions(
new JksOptions().setPath("server-keystore.jks").setPassword("wibble")
);
HttpClient client = vertx.createHttpClient(options);
client.request(HttpMethod.GET, 4443, "localhost", "/")
.compose(req -> req.send()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpVersion;
import io.vertx.core.net.PemKeyCertOptions;
import io.vertx.example.util.Runner;

/*
* @author <a href="http://tfox.org">Tim Fox</a>
* @author linghengqian
*/
public class Client extends AbstractVerticle {

Expand All @@ -27,7 +29,8 @@ public void start() throws Exception {
setSsl(true).
setUseAlpn(true).
setProtocolVersion(HttpVersion.HTTP_2).
setTrustAll(true);
setTrustAll(true).
setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("server-key.pem").setCertPath("server-cert.pem"));

HttpClient client = vertx.createHttpClient(options);

Expand All @@ -49,6 +52,6 @@ public void start() throws Exception {
request.writeCustomFrame(10, 0, Buffer.buffer("ping"));
});
});
});
}).onFailure(Throwable::printStackTrace);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import io.vertx.core.AbstractVerticle;
import io.vertx.core.http.*;
import io.vertx.core.net.PemKeyCertOptions;
import io.vertx.example.util.Runner;

/*
* @author <a href="http://tfox.org">Tim Fox</a>
* @author linghengqian
*/
public class Client extends AbstractVerticle {

Expand All @@ -23,11 +25,12 @@ public void start() throws Exception {
setSsl(true).
setUseAlpn(true).
setProtocolVersion(HttpVersion.HTTP_2).
setTrustAll(true);
setTrustAll(true).
setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("server-key.pem").setCertPath("server-cert.pem"));

HttpClient client = vertx.createHttpClient(options);

client.request(HttpMethod.GET, 8080, "localhost", "/").compose(request -> {
client.request(HttpMethod.GET, 8443, "localhost", "/").compose(request -> {

// Set handler for server side push
request.pushHandler(pushedReq -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

/*
* @author <a href="http://tfox.org">Tim Fox</a>
* @author linghengqian
*/
public class Server extends AbstractVerticle {

Expand Down Expand Up @@ -37,8 +38,6 @@ public void start() throws Exception {
System.out.println("sending push");
HttpServerResponse pushedResp = ar.result();
pushedResp.sendFile("script.js");
} else {
// Sometimes Safari forbids push : "Server push not allowed to opposite endpoint."
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpVersion;
import io.vertx.core.net.PemKeyCertOptions;
import io.vertx.example.util.Runner;

/*
* @author <a href="http://tfox.org">Tim Fox</a>
* @author linghengqian
*/
public class Client extends AbstractVerticle {

// Convenience method so you can run it in your IDE
public static void main(String[] args) {
Runner.runExample(Client.class);
}

@Override
public void start() throws Exception {

Expand All @@ -20,16 +28,16 @@ public void start() throws Exception {
setSsl(true).
setUseAlpn(true).
setProtocolVersion(HttpVersion.HTTP_2).
setTrustAll(true);

setTrustAll(true).
setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("server-key.pem").setCertPath("server-cert.pem"));
HttpClient client = vertx.createHttpClient(options);
client.request(HttpMethod.GET, 8080, "localhost", "/")
client.request(HttpMethod.GET, 8443, "localhost", "/")
.compose(req -> req.send()
.compose(resp -> {
System.out.println("Got response " + resp.statusCode());
return resp.body();
})).onSuccess(body -> {
System.out.println("Got data " + body.toString("ISO-8859-1"));
}).onFailure(Throwable::printStackTrace);
System.out.println("Got data " + body.toString("ISO-8859-1"));
}).onFailure(Throwable::printStackTrace);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.vertx.example.core.net.echossl;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.net.JksOptions;
import io.vertx.core.net.NetClientOptions;
import io.vertx.core.net.NetSocket;
import io.vertx.example.util.Runner;
Expand All @@ -18,7 +19,9 @@ public static void main(String[] args) {
@Override
public void start() throws Exception {

NetClientOptions options = new NetClientOptions().setSsl(true).setTrustAll(true);
NetClientOptions options = new NetClientOptions().setSsl(true).setTrustAll(true)
.setKeyStoreOptions(new JksOptions().setPath("server-keystore.jks")
.setPassword("wibble"));

vertx.createNetClient(options).connect(1234, "localhost", res -> {
if (res.succeeded()) {
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 17bb16b

Please sign in to comment.