Add option to return the headers of the message

This commit is contained in:
Ricardo Georgel 2021-06-27 15:18:58 -03:00
parent 8a22cc7114
commit 23b9e7bbe1

View file

@ -122,6 +122,13 @@ export class KafkaTrigger implements INodeType {
default: 30000, default: 30000,
description: 'The time to await a response in ms.', description: 'The time to await a response in ms.',
}, },
{
displayName: 'Return headers',
name: 'returnHeaders',
type: 'boolean',
default: false,
description: 'Return the headers received from Kafka',
},
], ],
}, },
], ],
@ -199,6 +206,16 @@ export class KafkaTrigger implements INodeType {
} catch (error) { } } catch (error) { }
} }
if (options.returnHeaders) {
const headers: {[key: string]: string} = {};
for (const key in message.headers) {
const header = message.headers[key];
headers[key] = header?.toString('utf8') || '';
}
data.headers = headers;
}
data.message = value; data.message = value;
data.topic = topic; data.topic = topic;