async def parse_message(
self,
message: Msg,
) -> StreamMessage[Msg]:
headers = message.header or {}
handler = context.get("handler_")
path: AnyDict = {}
path_re: Optional[Pattern[str]]
if ( # pragma: no branch
handler
and (path_re := handler.path_regex) is not None
and (match := path_re.match(message.subject)) is not None
):
path = match.groupdict()
return NatsMessage(
is_js=self.is_js,
raw_message=message,
body=message.data,
path=path,
reply_to=headers.get("reply_to", "") if self.is_js else message.reply,
headers=headers,
content_type=headers.get("content-type", ""),
message_id=headers.get("message_id", str(uuid4())),
correlation_id=headers.get("correlation_id", str(uuid4())),
)