BlackSheep icon indicating copy to clipboard operation
BlackSheep copied to clipboard

request.scope["root_path"] not set

Open ohait opened this issue 4 months ago • 3 comments

Apologies if this is misleading or plain wrong, I'm still figuring out a lot about blacksheep. I am trying to generate some metrics on the requests coming to my service, and we use path templates like /get/:id. as of now, the prometheus middleware uses request.url.path.decode("utf-8") but given the above template, it will generate a lot of cardinality. Looking at ASGI docs, i expected request.scope["root_path"] to contains the original /get/:id path, instead of the url in the request, but it's always empty, while request.route_values is correctly set.

I tracked down the place where the routing take places here: https://github.com/Neoteroi/BlackSheep/blob/026897ff2796c2f2074cb368ff9c59a262dc28ad/blacksheep/baseapp.pyx#L78

is there a missing assignment for the request.scope? or am i completely off and there is an easier way?

ohait avatar Apr 02 '24 13:04 ohait