Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to pure ASGI Middleware #150

Closed
adriangb opened this issue Jun 11, 2022 · 2 comments
Closed

Port to pure ASGI Middleware #150

adriangb opened this issue Jun 11, 2022 · 2 comments

Comments

@adriangb
Copy link
Contributor

Hi, I am a Starlette maintainer. We are trying to get folks moved away from BaseHTTPMiddleware because it has several unfixable bugs and performance issues. One of the highest impact ways of doing this is going to be porting downstream packages (like this one) to pure ASGI middleware.

Taking a look at the package, it seems like it would be pretty straightforward to port the middleware itself to a pure ASGI middleware. The part that is going to be tricky is that the API sends Request/Response objects into user's functions. That part can't really be changed. What I'd proposed is creating a Request object with a placeholder receive that raises an error if called (i.e. you can't access the Request body) and maybe a Response that can't be run (i.e. Response.__call__ raises an exception).

To be clear I am volunteering my time to do this, but I will need review, some discussion about the above issues, etc.

Does this sound reasonable @trallnag?

@trallnag
Copy link
Owner

Hey @adriangb, sounds good. But beware my lack of knowledge regarding Python ASGI. Also check out this pull request: #139. I think @Kludex has already (partially?) worked on replacing the middleware

@adriangb
Copy link
Contributor Author

Oh I missed that, Marcelo is always one step ahead 😄. I'll close this in favor of #139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants