webhooks.http48 lines, 1.6 KB
| 1 | # Webhooks, through the gateway. Run transfers.http first: Alice needs a |
| 2 | # wallet, and someone to pay. The receiver: go run ./cmd/webhook-receiver |
| 3 | @baseUrl = http://localhost:8080 |
| 4 | @token = {{login.response.body.access_token}} |
| 5 | @endpointId = {{endpoint.response.body.id}} |
| 6 | |
| 7 | ### Log in as Alice |
| 8 | # @name login |
| 9 | POST {{baseUrl}}/v1/auth/login |
| 10 | Content-Type: application/json |
| 11 | |
| 12 | {"email": "alice@example.com", "password": "correct horse battery staple"} |
| 13 | |
| 14 | ### Register an endpoint |
| 15 | # @name endpoint |
| 16 | POST {{baseUrl}}/v1/webhooks/endpoints |
| 17 | Authorization: Bearer {{token}} |
| 18 | Content-Type: application/json |
| 19 | |
| 20 | { |
| 21 | "url": "http://host.docker.internal:8090/webhooks", |
| 22 | "event_types": ["transfer.completed.v1", "transfer.failed.v1"] |
| 23 | } |
| 24 | |
| 25 | ### The delivery log |
| 26 | # @name deliveries |
| 27 | GET {{baseUrl}}/v1/webhooks/deliveries?endpoint={{endpointId}} |
| 28 | Authorization: Bearer {{token}} |
| 29 | |
| 30 | ### Replay the latest delivery |
| 31 | POST {{baseUrl}}/v1/webhooks/deliveries/{{deliveries.response.body.$.deliveries[0].id}}/replay |
| 32 | Authorization: Bearer {{token}} |
| 33 | |
| 34 | ### A forged webhook, straight to the receiver |
| 35 | POST http://localhost:8090/webhooks |
| 36 | Content-Type: application/json |
| 37 | Webhook-Id: 0195f1c2-7d3e-7a10-9c4b-2f6e8d1a0b37 |
| 38 | Webhook-Timestamp: {{$timestamp}} |
| 39 | Webhook-Signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4= |
| 40 | |
| 41 | {"type": "transfer.completed.v1", "data": {"amount": 100000000, "currency": "USD"}} |
| 42 | |
| 43 | ### Not the cloud's metadata service |
| 44 | POST {{baseUrl}}/v1/webhooks/endpoints |
| 45 | Authorization: Bearer {{token}} |
| 46 | Content-Type: application/json |
| 47 | |
| 48 | {"url": "http://169.254.169.254/latest/meta-data/", "event_types": ["transfer.completed.v1"]} |