aries-framework-go
aries-framework-go copied to clipboard
Webhook has no content type in header
- Are you filing a bug report? bug, enhancement
What I'm trying to do I'm trying to implement a controller (typescript -Nestjs) and I have enabled a rest endpoint for webhook to receive notified messages from my Agent.
The Agent has the following flag --webhook-url http://host.docker.internal:3001/webhook
Expected result The post request coming from notifier has a content type in header and the message is in body and the receiver can get the message like this
@Post('/webhook')
webhook(@Body() body): any {
this.logger.debug('--Webhook Message--');
this.logger.debug(JSON.stringify(body));
}
Actual result The Post request does not have a Content-Type
User-Agent Go-http-client/1.1
Content-Length 496
Accept-Encoding gzip
and therefore the receiver cannot parse it correctly. currently I need to do something like this to get the message:
@Post('/webhook')
webhook(@Request() req: express.Request): any {
var body = '';
var messageAsJson = '';
req.on('data', function (data) {
body += data;
// Too much POST data, kill the connection!
if (body.length > 1e6) {
req.socket.destroy()
}
});
req.on('end', () => {
messageAsJson = JSON.parse(body.replace("[object Object]", ""));
this.logger.debug('--Webhook Message--');
this.logger.debug(JSON.stringify(messageAsJson));
});
return true
}