Is it possible to get the message key when using the fastapi plugin? #1330
Answered
by
Lancetnik
iamvishnuks
asked this question in
Q&A
-
Hi I have a bare minimum code as below,
When I print the msg I am able to parse the message value which was in json format, but how could I get the message key from it. I couldn't find any examples in fastapi plugins docs. Can anyone please help. Thanks!! |
Beta Was this translation helpful? Give feedback.
Answered by
Lancetnik
Apr 1, 2024
Replies: 1 comment 2 replies
-
You can use So, you should get it by smth like this: from faststream.confluent.fastapi import Context
@router.subscriber("test")
async def base_handler(
body: str,
key: str = Context("message.raw_message.key"),
):
print(key) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
iamvishnuks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use
faststream.confluen.fastapi.Context
the same way with the regular one: https://faststream.airt.ai/latest/confluent/message/#message-fields-accessSo, you should get it by smth like this: