I want to use Knative Sequence to chain few ksvcs but failed. The first step ksvc can be triggered but not the rest of them.
In my ksvc(Node.js), I used CloudEvent js-sdk. I assume I would need to return a new CloudEvent after receiving it. So here comes my code:
app.post('/', (req, res)=>{
const event = HTTP.toEvent({ headers: req.headers, body: req.body });
// respond as an event
const responseEventMessage = new CloudEvent({
source: '/',
type: 'event:response',
...event
});
responseEventMessage.data = {
hello: 'world'
};
res.status(201).json(responseEventMessage);
})
I believe
HTTP.binary()
orHTTP.structured()
should be used to transform event to headers and body.Edit: It might be required to set up body-parser.
Also it's better to use
cloneWith()
instead of spreading.