-
-
Notifications
You must be signed in to change notification settings - Fork 932
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
Improve wording and structure of pure ASGI middleware docs #1723
Conversation
3ba4215
to
a380c74
Compare
I read over the markdown version. It looks very nice to me, thank you for working on this! I think ASGI middleware is now one of the most comprehensive and well thought out sections of the docs, go team! |
amazing @florimondmanca ! |
Thanks :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the way you write. :)
Added some humble comments 🙏
@@ -226,20 +235,20 @@ Middleware classes should not modify their state outside of the `__init__` metho | |||
Instead you should keep any state local to the `dispatch` method, or pass it | |||
around explicitly, rather than mutating the middleware instance. | |||
|
|||
!!! warning | |||
Currently, the `BaseHTTPMiddleware` has some known limitations: | |||
### Limitations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually pay more attention to things when I see admonitions. 🤔 Just saying... Feel free to close it. 😗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The motivation there was to make add those limitations as a section in the navigation, so it's obvious when searching for the "BaseHTTPMiddleware documentation" that "Okay, I can use this, but there are limitations". On the other hand admonitions require scrolling through the actual content to tell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doc is so detailed and elaborate! Thanks for this one!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some details on custom Responder? (If it makes sense, and is relevant)
feel free to close
e07b081
to
4f5b17f
Compare
Blocked by… tomchristie/mkautodoc#33 (Not that keen to do an equivalent of encode/httpx#2313 for every Encode project that will be affected through using |
There's no hurry for the next release, so I guess it's fine to wait. Did you also ping Tom privately on Gitter about this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @florimondmanca 🙏
Merging since I believe this is ready given the resolution of comments and approvals. Thanks all for reviewing! |
Great work @florimondmanca ! Especially the Common Patterns section; I just used it to write my own pure ASGI middleware. That said, newcomers are undoubtedly still gonna be a bit thrown compared to |
I just wanted to say: this is written very clearly, thank you for the work @florimondmanca ! |
This PR is a follow-up based on @Kludex's comment here: #1656 (review)
I went ahead and reviewed the structure of the "Pure ASGI middleware" section, which now looks like this...
Some other notable changes:
receive
("Inspecting or modifying the request").http.request
,http.response.start
, etc). Surely, we know them by heart by now 😄 but we can't assume folks will guess what those contain or where to find that info.nonlocal
syntax ("Do") vs storing in attributes ("Don't").(I also tweaked some parts outside of the "Pure ASGI" section, mostly for ensuring consistency; happy to defer to a different PR if that seems out of scope.)
To review, you may view the docs locally, using
scripts/docs
.