From CRUD to REST
Now that we have a Repository, we can use it in our microservice to perform the operations that our microservice will expose. So, let's try to modify our previously created reactive RESTful operations into CRUD operations in our database and answer back to whoever invoked it reactively.
Note
We learned how to create reactive RESTful Microservices in Chapter 4, Creating Reactive Microservices. We'll use some of the code that was created during that chapter; if you are not familiar with it, you may want to review the content of that chapter.
Bringing back our service
Previously, we have created a service class to hide the implementation details how we persist in our Model, so let's do it again by creating a CustomerService
interface, for now, just a method to get a Customer
from an id
:
package com.microservices.chapter5 import reactor.core.publisher.Mono interface CustomerService { fun getCustomer(id: Int): Mono<Customer> }
Now, we will create the implementation of the...