Webhooks¶
Setup¶
Setup the hook on the actor using xbusctl:
xbusctl actor config set <actor name> http.webhook.url=http<...>
Optionaly, set a message content-type (‘application/json’ (default) or ‘application/x-protobuf’).
xbusctl actor config set <actor name> http.webhook.content-type=<content-type>
For example:
xbusctl actor config set my-frontend-consumer http.webhook.url=https://myfrontend.com/webhook/somehardtoguesswebpath
Warning
The xbus-http instance must be restarted after setting up a webhook.
API¶
The gateway will POST new requests on the url.
The response must be a properly encoded ActorProcessingState. If not, the process will fail.
If the status of the returned state is ‘RUNNING’, the client must call ‘/processingend’ later.
Example request:
POST /my/hook/webpath HTTP/1.1
Host: example.com
Accept: application/json
Accept-Item-Encoding: binary
Content-Type: application/json
{
"context": {},
"inputs": [{
"name": "default",
"envelope": {
"event_ids": ["53131466-4e2e-11e7-916e-af2b1e6d242d"],
"events": [{
"id": "53131466-4e2e-11e7-916e-af2b1e6d242d",
"type": "test",
"ItemCount": 1,
"encoding": "binary",
"items": ["QSBtZXNzYWdl"]
}]
},
"envelopeposition": {
"envelope_id": "53131466-4e2e-11e7-916e-af2b1e6d242d",
"start": true,
"complete": true,
"eventPosisions": [{
"event_id": "53131466-4e2e-11e7-916e-af2b1e6d242d",
"index": 1,
"itemCount": 1
}]
}
}]
}
Example response
{
"context": {},
"status": "SUCCESS",
"messages": [{
"timestamp": "2018-08-20T22:56:12Z",
"level": "NOTICE",
"text": "Hello there"
}]
}