The RESTful web service

In this section, we will explore how to expose the RESTful API.

The main unit in Vert.x is the verticle—using this class, we will be able to handle, always in an asynchronous way, requests for our data.

We will create two classes: a helper needed to build the responses associated with specific HTTP verbs, and the verticle class, which exposes the API.

The ActionHelper class is an easy utility class that helps us build responses:

public class ActionHelper {    /**     * Returns a handler writing the received {@link AsyncResult} to the routing     * context and setting the HTTP status to the given status.     *     * @param context the routing context     * @param status the status     * @return the handler     */ private static <T> Handler<AsyncResult<T>> ...

Get Hands-On Cloud-Native Microservices with Jakarta EE now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.