Exposing our service via an open host service
We have a requirement that our service must also expose an API. This is so other microservices or user interfaces may call us to get a recommendation. One method we could use to do this is to generate an API using OpenAPI or gRPC, as we discussed in Chapter 2. However, for completeness, we are going to write this one from scratch.
Let’s define a contract first. We are going to create an API that receives the following request:
/recommendation?location=$country?from=$date&to=$date&budget =$budget
It returns the following response:
{ "hotelName": "hotel Name", "totalCost": { "cost": 300, "currency": "USD" } }
Notice how the response we intend to return is different from the partnership system? This is completely normal. We own our domain...