You can use Erlang + Cowboy to simulate a swamp of pox style HTTP API.
appointment(#{<<"openSlotRequest">> := Slot}, Req0) ->
appointment(open, Slot, Req0);
appointment(#{<<"appointmentRequest">> := Booking}, Req0) ->
appointment(request, Booking, Req0).
You don't need Erlang installed to run this app if you use containers.
# Compile the app
rebar3 compile
# Build the binary
rebar3 release
# docker build & run
docker build --tag ajb0wers/swamp .
docker run -p 8080:8080 --rm ajb0wers/swamp
# Alternatively, using docker compose
docker compose up -d
# Open slots on a given date.
curl 'http://127.0.0.1:8080/appointmentService/' --json '
{
"openSlotRequest": {
"date": "2010-01-04",
"doctor": "mjones"
}
}'
# Book an appointment.
curl 'http://127.0.0.1:8080/appointmentService/' --json '
{
"appointmentRequest": {
"slot": {
"doctor": "mjones",
"start": "1400",
"end": "1450"
},
"patient": {
"id": "jsmith"
}
}
}'
- Richardson Maturity Model - wikipedia.org
- REST APIs must be hypertext-driven (2008) - roy.gbvi.com
- Should we rebrand REST? (2021) - kieranpotts.com
- Cowboy HTTP Server - ninenines.eu