Skip to content

ajb0wers/swamp

Repository files navigation

level 0: Swamp of POX

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.

Build

# Compile the app
rebar3 compile

# Build the binary
rebar3 release

Run

# docker build & run
docker build --tag ajb0wers/swamp .
docker run -p 8080:8080 --rm ajb0wers/swamp

# Alternatively, using docker compose
docker compose up -d

Examples

# 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"
    }
  }
}'

See also

About

You can use Erlang + Cowboy to simulate a swamp of pox style HTTP API.

Topics

Resources

License

Stars

Watchers

Forks