Questions Management – API Option Service – Build API update option using Spring WebFlux

Check out the full series of Questions Management tutorial here.

In the previous tutorial, we prepared all the necessary configurations to be able to build API update option such as: an object containing all the information of an Option; a CoreOptionService interface with the implementation CoreOptionServiceImpl is responsible for handling the Core Option Service; an OptionController defines the APIs of the API Option Service that will start with “/option” and information about the Core Option Service is configured in the application.properties file. Now, let’s build this API!

To build API update option, I will first add a new updateOption() method in the CoreOptionService interface:

The implementation of this method calls the Core Option Service in the CoreOptionServiceImpl class as follows:

As you can see, here I have used the WebClient object to connect to the Core Option Service and call the API to update the option of this service with the “/option/{id}” URI.

Next, I will add a method call to the CoreOptionService updateOption() method to expose a PUT request “/option/{id}” in OptionController as follows:

At this point, we have completed the API update option for the API Option Service. Let’s try it.

Questions Management – API Option Service – Build API update option using Spring WebFlux

Add Comment