16 — Webhooks
A webhook is a signal to the flow that waits for it.
In Go
// hmac.Equal and a 401, in every webhook handlerendpoint(handlers.contract_signed, at: Post(app.routes.ContractSigned), from: app.apis.signing) { signature(incoming) { match map.get(incoming.headers, key: "x-signature") { Some(hex) -> Some(http.Signature { key: config.signing_key message: bytes.of(incoming.body) sent: [Hex { text: hex }] }) None -> None } } request(incoming) { match json.input<SignedEvent>(incoming.body) { Valid { value: event } -> Accepted { input: event.employee } Invalid { refused, .. } -> Refused { reply: http.refused(refused) } } } reply(result) { match result { Delivered -> http.Reply { status: 200, headers: [:], body: "" } Ended -> http.Reply { status: 200, headers: [:], body: "onboarding has ended" } } } }