Questions Management – API Question Service – Build API update question using Spring WebFlux

Check out the full series of Questions Management tutorial here.

In the previous tutorial, we prepared all the necessary configurations to build API update question such as: an object containing all the information of a question CompositeQuestion including Question, Category, and Option; a CompositeQuestionService interface with CompositeQuestionServiceImpl implementation is responsible for handling the Composite Question Service, an ApiQuestionController that defines the APIs of API Question Service will start with a “/question” and information about the Composite Question Service is configured in the application.properties file. Now, let’s build this API!

To build API update a question, first, I will add an updateQuestion() method in the CompositeQuestionService interface:

The implementation of this method calls to the Composite Question Service in the CompositeQuestionServiceImpl class as follows:

As you can see, here I have used the WebClient object to connect to the Composite Question Service and call the API to update  a question with the “/question/{id}” URI.

Next, I will add a method call to the CompositeQuestionService’s updateQuestion() method to expose a PUT request “/question/{id}” in ApiQuestionController as follows:

At this point, we have completed the API update question for the API Question Service. Let’s test it.

Questions Management – API Question Service – Build API update question using Spring WebFlux

Questions Management – API Question Service – Build API update question using Spring WebFlux
Đánh giá bài viết
Chia sẽ bài viết này ...Share on Facebook
Facebook
2Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

Add Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.