Demo of KrakenD's API gateway functionality using Grand Oak & Pine Valley Hospital Mock API
Run this command:
docker-compose up
Or if you want to run the services individually, follow these steps:
To run the mock backend, simply use this command:
java -jar ./mock-backend/DoctorInfo-JDK11.jar
To run the adapter service, do these sequence of commands:
cd pinevalley-adapter
npm i
node index.js
This adapter is needed because you need KrakenD enterprise to actually send POST request with bodies, sigh.
To run the API gateway, do these sequence of commands:
docker pull devopsfaith/krakend
docker run -p 8080:8080 -v "${PWD}:/etc/krakend/" devopsfaith/krakend
These are the valid values for doctor type:
- Ophthalmologist
- Physician
- Pediatrician
GET http://localhost:9091/grandOak/doctors/<doctorType>
Here is the response:
{
"doctors": {
"doctor": [
{
"name": "Bob Watson",
"time": "05:30 PM",
"hospital": "Grand Oak"
},
{
"name": "Paul Johnson",
"time": "07:30 AM",
"hospital": "Grand Oak"
}
]
}
}
POST http://localhost:9090/pineValley/doctors
, send with this body:
{
"doctorType": "<doctorType>"
}
Here is the response:
{
"doctors": {
"doctor": [
{
"name": "Bob Watson",
"time": "07:30 AM",
"hospital": "pineValley"
},
{
"name": "Wilson Mcdonald",
"time": "07:30 AM",
"hospital": "pineValley"
}
]
}
}
GET http://localhost:9092/pineValley/doctors/<doctorType>
Here is the response:
{
"doctors": {
"doctor": [
{
"name": "Bob Watson",
"time": "07:30 AM",
"hospital": "pineValley"
},
{
"name": "Wilson Mcdonald",
"time": "07:30 AM",
"hospital": "pineValley"
}
]
}
}
GET http://localhost:8080/doctors/<doctorType>
Here is the response:
{
"doctors": {
"doctor": [
{
"hospital": "Grand Oak",
"name": "John Mathew",
"time": "03:30 PM"
},
{
"hospital": "Grand Oak",
"name": "Allan Silvester",
"time": "04:30 PM"
},
{
"hospital": "pineValley",
"name": "John Mathew",
"time": "07:30 AM"
},
{
"hospital": "pineValley",
"name": "Roma Katherine",
"time": "04:30 PM"
}
]
}
}