Replies: 2 comments 3 replies
-
|
It looks like you are missing concepts. Maybe the Middleware page on the starlette documentation can help. |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
This is what I have been using, without constructing a new request object response = await call_next(request)
content = [gen async for gen in response.body_iterator]
async def list_to_async_iterator(body_list):
for part in body_list:
yield part
response.body_iterator = list_to_async_iterator(content)
logging.info(f"RESPONSE {response.status_code} {response.raw_headers} {(b''.join(content)).decode('latin-1')}")
return response |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
I'm trying to access the request response data inside a custom http middleware that is supposed to shadow the original one from the
Starlettelibrary, but I'm unable to do it, the coroutine returnsNone- but I'm thinking there must be a way as the response gets to the client without any issues. Any tips, explanation or further links would be much appreciated.Apologies in advance if this question should've been posted in Starlette's discussions, I wasn't sure.
Operating System
macOS
Operating System Details
No response
FastAPI Version
0.101.0
Pydantic Version
2.1.1
Python Version
3.11.3
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions