Skip to content

Commit

Permalink
Different start method in Get Started guide and starter
Browse files Browse the repository at this point in the history
Fixes #162

The snippet used a different start method declaration than the start
method generated by the starter.
Users could get confused by copy/pasting only the body of the method and
missing to complete/or fail the start promise.

Besides, the sample didn't have imports so the user had to figure
them out without any indication.

Also, updated the screenshot (latest version of the starter).
  • Loading branch information
tsegismont committed Sep 2, 2024
1 parent d706d01 commit a729217
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Binary file modified assets/get-started/starter-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 20 additions & 7 deletions pages/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,18 @@ Change the code as follows:
<CodeExample title="Java">

```java
package com.example.starter;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.MultiMap;
import io.vertx.core.Promise;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.Router;

public class MainVerticle extends AbstractVerticle {

@Override
public void start() throws Exception {
public void start(Promise<Void> startPromise) throws Exception {
// Create a Router
Router router = Router.router(vertx);

Expand All @@ -93,12 +102,16 @@ public class MainVerticle extends AbstractVerticle {
.requestHandler(router)
// Start listening
.listen(8888)
// Print the port
.onSuccess(server ->
System.out.println(
"HTTP server started on port " + server.actualPort()
)
);
// Print the port on success
.onSuccess(server -> {
System.out.println("HTTP server started on port " + server.actualPort());
startPromise.complete();
})
// Print the problem on failure
.onFailure(throwable -> {
throwable.printStackTrace();
startPromise.fail(throwable);
});
}
}
```
Expand Down

0 comments on commit a729217

Please sign in to comment.