Creating a custom Actuator endpoint
In our example, we are developing a new RESTful API that requires a file to be loaded from blob storage. That file doesn’t change frequently, which means it’s loaded in memory at application startup and is not reloaded again automatically. You need to know which version of the file is loaded, and you want to force a reload when there is a new version.
To implement this feature, you will use a custom Actuator endpoint. This endpoint will have a GET
operation to return the current file version, and a POST
method to reload the file.
Getting ready
In this recipe, you will reuse the application you created in the Adding Actuator to your application recipe. I’ve prepared a working version in this book’s GitHub repository at https://github.com/PacktPublishing/Spring-Boot-3.0-Cookbook/. It can be found in the chapter3/recipe3-2/start
folder.
How to do it…
Let’s modify the RESTful API so that it loads...