Exposing a web API

Tip
The corresponding source code is in the step-6 folder of the guide repository.

Exposing a web HTTP/JSON API is very straightforward using what we have already covered from the vertx-web module. We are going to expose a web API with the following URL scheme:

  • GET /api/pages gives a document will all wiki page names and identifiers,

  • POST /api/pages creates a new wiki page from a document,

  • PUT /api/pages/:id updates a wiki page from a document,

  • DELETE /api/pages/:id deletes a wiki page.

Here is a screenshot of interacting with the API using the HTTPie command-line tool:

webapi httpie