From the course: Creating Your First Spring Boot Microservice

Unlock the full course today

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

Creating APIs with Spring Data REST

Creating APIs with Spring Data REST

From the course: Creating Your First Spring Boot Microservice

Start my 1-month free trial

Creating APIs with Spring Data REST

- [Instructor] So let's get down to coding these APIs. So let's call the API to get all the tour packages. We need an endpoint called tourPackages such that HttP Get /tourPackages fetches all the tourPackages in JSON format. Httpget/tourPackages/code, fetches one tour package with the provided code. Ready, set go! Done! I'm not kidding you. Because we included Spring Data Rest as one of our project dependencies, there is no coding necessary to implement these APIs. At application startup, Spring Data Rest scans the class files and finds the spring data repositories, creates an endpoint that matches the entity name, appends and S, and exposes the operations as APIs. So here, we have the mapping for create. Which sit eh HTTP Post. The mappings for read, which is HTTP Get for all or one. The mappings for update which is HTTP Put or Patch. This requires looking up the entity first and finally, delete, which is HTTP…

Contents