Skip to content

Commit 217ff97

Browse files
committed
add a route for sparkpi
This also places the common info text at the root index endpoint.
1 parent 8e4912c commit 217ff97

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# vertx-sparkpi
2-
A Java implementation of SparkPi using Vert.x 3
2+
A Java implementation of SparkPi using Vert.x 3
33

44
This application is an example tutorial for the
55
[radanalytics.io](http://radanalytics.io) community. It is intended to be
@@ -32,5 +32,8 @@ You should have access to an OpenShift cluster and be logged in with the
3232
1. Visit the exposed URL with your browser or other HTTP tool, for example:
3333
```bash
3434
$ curl http://`oc get routes/vertx-sparkpi --template='{{.spec.host}}'`
35-
Pi is rouuuughly 3.1335
35+
Java Vert.x SparkPi server running. Add the 'sparkpi' route to this URL to invoke the app.
36+
37+
$ curl http://`oc get routes/vertx-sparkpi --template='{{.spec.host}}'`/sparkpi
38+
Pi is roughly 3.140480
3639
```

src/main/java/io/radanalytics/examples/vertx/SparkPiVerticle.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class SparkPiVerticle extends AbstractVerticle {
2424
private static final Logger log = Logger.getRootLogger();
2525
private Properties prop = null;
2626

27-
// vertx-config has more exotic options using Futures
27+
// vertx-config has more exotic options using Futures
2828
// and AsyncResult handlers, but this is all we need
2929
private String loadJarProperty() {
3030
if (null==prop) {
@@ -65,6 +65,13 @@ public void run() {
6565
SparkPiProducer pi = new SparkPiProducer();
6666

6767
router.route("/").handler(routingContext -> {
68+
HttpServerResponse response = routingContext.response();
69+
response
70+
.putHeader("content-type", "text/html")
71+
.end("Java Vert.x SparkPi server running. Add the 'sparkpi' route to this URL to invoke the app.");
72+
});
73+
74+
router.route("/sparkpi").handler(routingContext -> {
6875
HttpServerResponse response = routingContext.response();
6976
response
7077
.putHeader("content-type", "text/html")

0 commit comments

Comments
 (0)