From the course: Creating Your First Spring Boot Microservice

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Create RestController HTTP PUT, PATCH, and DELETE methods

Create RestController HTTP PUT, PATCH, and DELETE methods

From the course: Creating Your First Spring Boot Microservice

Start my 1-month free trial

Create RestController HTTP PUT, PATCH, and DELETE methods

- [Narrator] Now we are able to implement HTTP PUT, PATCH, and DELETE. So we're back in our TourRatingController and I have another helper method and it's on line 91 and this will verify a tour rating given a tourId and a customerId. It checks the unique tour rating for that tour and if it's not there it will throw a NoSuchElementException. If there is it will return that rating. So now I'm going to put in the body for the PUT and PATCH methods. I'm just going to paste that in. So here is our update with Put. It'll return a RatingDto on line 84. So we have a tourId and a Rating Dto passed in and so the semantics with PUT is that all the attributes are updated. The semantics of PATCH is to only update some methods of the entity. The methods are similar but we need to respect the intent of the API. So on 85 I call the method verifyTourRating and so I use the tourId passed in on the URL and then from the RatingsDto I…

Contents