From 23b9e7bbe151e2edd9436619c19d3fd11f6d9b80 Mon Sep 17 00:00:00 2001 From: Ricardo Georgel Date: Sun, 27 Jun 2021 15:18:58 -0300 Subject: [PATCH] Add option to return the headers of the message --- .../nodes-base/nodes/Kafka/KafkaTrigger.node.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts b/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts index c4587beca3..10a0034223 100644 --- a/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts +++ b/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts @@ -122,6 +122,13 @@ export class KafkaTrigger implements INodeType { default: 30000, 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) { } } + 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.topic = topic;