Create a simple pub/sub system using webhooks. It will require you to create two servers, a publisher and a subscriber.
Publisher Server Requirements
- publish a payload to topic
- subscribe to a topic to receive payloads
POST /publish/{topic}
body: {payload}
POST /subscribe/{topic}?callback_url={subscriberServerEndpoint}
Subscriber Server Requirements
POST /event
// output
{topic:”foo”, “payload”: “this is the payload”}
Example using shell commands
$ ./start-producer.sh 8001
$ ./start-consumer.sh 8002
$ curl -X POST http://localhost:8001/subscribe/foo?callback_url=http://localhost:8002/event
$ curl -X POST -H "Content-Type: application/json" -d '{"data": "hello"}' http://localhost:8001/publish/foo
then the subscriber server would print out what it received