Skip to content

Is it possible to get the message key when using the fastapi plugin? #1330

Answered by Lancetnik
iamvishnuks asked this question in Q&A
Discussion options

You must be logged in to vote

You can use faststream.confluen.fastapi.Context the same way with the regular one: https://faststream.airt.ai/latest/confluent/message/#message-fields-access

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)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@iamvishnuks
Comment options

@Lancetnik
Comment options

Answer selected by iamvishnuks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants