Show webhooks
A webhook is an HTTP request that a service sends to you when something occurs. streamview makes one event from each webhook. It does not need CloudEvents, an adapter, or Node.js.
streamview does not check the signature of a webhook. It shows each request that arrives.
Start streamview
Section titled “Start streamview”Run this command:
streamview webhooksThe browser opens. The page is empty until the first webhook arrives.
Send a test webhook
Section titled “Send a test webhook”- Run this command in a different terminal:
curl -X POST http://localhost:4747/webhooks/shop \ -H 'Content-Type: application/json' \ -d '{"event":"order.paid","orderId":"ord_1","total":42}'- Read the answer:
{"accepted":true,"type":"shop.order.paid","id":"wh-1a23ad82ed3-0"}- Look at the page. After approximately 2 seconds, the event shows in the lane
shop.order.paid.
Give each service an address
Section titled “Give each service an address”The address of a webhook is /webhooks/NAME. You select the name.
Use one name for each service, for example /webhooks/stripe and /webhooks/github.
The name can have letters, digits, and the characters ., _, and -.
The name is the start of the event type, and it is the channel of the event.
streamview finds the kind of the event in the headers or in the body of the webhook.
Each kind gets a lane of its own, for example stripe.payment_intent.succeeded and stripe.charge.refunded.
See Events from webhooks for the places where streamview looks.
Receive webhooks from a service on the internet
Section titled “Receive webhooks from a service on the internet”A service on the internet cannot connect to localhost. A tunnel gives your computer a public address.
These steps use cloudflared, the tunnel program of Cloudflare. Other tunnel programs work the same way.
- Start streamview:
streamview webhooks. - Run this command in a different terminal:
cloudflared tunnel --url http://localhost:4747- Find the address in the output. It ends with
trycloudflare.com. - In the settings of the service, give this webhook address: the public address, then
/webhooks/, then your name.
For example: https://example-words.trycloudflare.com/webhooks/stripe.
The public address can need some seconds before it works.
If the server runs on a computer that the service can connect to, you do not need a tunnel.
Start streamview with --host 0.0.0.0. See Share a view.
Give a webhook an icon
Section titled “Give a webhook an icon”Add icon to the address that you give to the service. An emoji is the simplest icon:
http://localhost:4747/webhooks/stripe?icon=💳The value can also be the address of an image. See The icon of a lane.
Set the type yourself
Section titled “Set the type yourself”If a service does not say what kind of event it sends, the type is only the name.
To give the type, add ?type= to the address:
https://example-words.trycloudflare.com/webhooks/builds?type=build.finishedAll webhooks to this address then have the type build.finished.
Connect the webhooks of one order
Section titled “Connect the webhooks of one order”streamview connects events that have the same correlation ID. Tell it which field of the body has the ID.
For all addresses, start streamview with --correlation-field:
streamview webhooks --correlation-field orderIdFor one address, add ?correlation-field= to the address:
http://localhost:4747/webhooks/stripe?correlation-field=data.object.metadata.order_id- Use a period to go into an object, as in
data.object.metadata.order_id. - Use a comma between two or more fields. streamview uses the first field that the body has.
When two services send the same ID, the trace shows their webhooks together.
Show webhooks and a broker together
Section titled “Show webhooks and a broker together”Each streamview server that stores events accepts webhooks: kafka, nats, rabbitmq, serve, and demo.
Send the webhooks to the same port. Their lanes show below the lanes of the broker.