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 GET methods
From the course: Creating Your First Spring Boot Microservice
Create RestController HTTP GET methods
- [Instructor] Now let's create two new APIs. One to look up all the ratings for a tour and the other to calculate the average score for all the ratings. I think it's best to hide the implementation of tourRating's entity from the API so we will return a list of tourDto objects. And we will calculate the average by setting the URL with a /average at the end. And then we will return adjacent packet with a key-value pair of the word average and then the actual average score. So we're back in our TourRatingController and I'm just going to paste in the body of these two methods. Because I know it's really thrilling for you guys to watch me type. I'm just going to do my imports. So this first method, getAllRatingsForTour you take the tourId in, verify that it's a tour ID. We're not going to use the return tourValue of verifyTour it's just going to do the lookup and if it's found it's fine if it's not found it'll throw an…
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)
-
-