I was developed a microservice with kafka and nestjs but the problem is when I want to transfer header gateway to service I am unable to do this I have an option for message section but I don't want to do this I want send it kafka header how can I do this
here is my code
export class UserService {
constructor(
@Inject('AUTH_MICROSERVICE') private readonly authClient: ClientKafka,
) {}
private readonly detector = new DeviceDetector({
clientIndexes: true,
deviceIndexes: true,
deviceAliasCode: false,
});
async subscribeResponse(messages: string[]) {
for (let i = 0; i < messages.length; i++) {
this.authClient.subscribeToResponseOf(messages[i]);
}
await this.authClient.connect();
}
async disconnect() {
await this.authClient.close();
}
send(message: string, data: any) {
return new Promise((resolve, reject) => {
this.authClient
.send(message, JSON.stringify(data))
.subscribe({
next: (response) => {
resolve(response);
},
error: (error) => {
reject(error);
},
});
});
}
async profile(profileDto: ProfileDto) {
return await this.send(profile, profileDto); // want to send header with this function from gateway
}
Please suggest way better way if you can suggest me