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
From the course: Creating Your First Spring Boot Microservice
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Choosing the right framework3m 26s
-
(Locked)
Declaring a new RestController3m 6s
-
(Locked)
Create RestController HTTP POST method8m 2s
-
(Locked)
Create RestController HTTP GET methods4m 48s
-
(Locked)
Create RestController HTTP PUT, PATCH, and DELETE methods6m 54s
-
(Locked)
Paging and sorting DTOs5m 1s
-
(Locked)
-
-