-
-
Notifications
You must be signed in to change notification settings - Fork 862
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
Some issues with the 'Calling into Python Web Apps' docs and API #396
Comments
Thanks for opening this comprehensive post! I'm so glad someone is giving our WSGI and ASGI support a run-around! 🙌 From reading this it looks like there are three distinct issues here:
If you don't want to get started on the top two right away I'd recommend we open a separate issue in our tracker for each so that others can potentially take up the work. Once created I'll close this issue. |
And, as I look back, I see "Review dispatch interface" in the 1.0 blockers issue... I'll definitely open separate tracking issues for the first 2. I may do those and the 3rd if nobody gets to them first. I'll get my Hacktoberfest PRs no problem either way, so I won't claim them : ) |
I think #407 mostly resolves this.
We could potentially unify
It's not 100% obvious if it's better for us to diverge from the specs there in order to have a consistent interface across both dispatch classes, but I could be convinced. |
In API design, a parameter should ideally be the smallest, atomic piece of information required from the user that, preferably, doesn't leak internals/implementations. As for the difference in the API between As for |
Just pitching in to say that I’ve seen people launch Twitter polls for these kinds of questions, and it seems to perform quite well. :) |
You can argue that it's spec APIs leaking into httpx, or argue that it's a case of not obfuscating away details behind a new and different abstraction. Both valid cases. I think I'm happy with |
I'd argue that the entirety of API design is purposeful obfuscation. The purpose being to create a better user experience. For example, httpx and requests accept In the case of the *SGIDispatch APIs, it's inconsequential to users that ASGI expects the address and port in one field as a 2-tuple while WSGI expects them in separate fields. It's only meaningful that a user can provide them if desired.
Is this just the
Except for those of us who don't use Twitter or any social media : ) |
Quick link to the section for reference. The example doesn't work due to
WSGIDispatch
not actually being available ashttpx.WSGIDispatch
. Rather, it's available ashttpx.dispatch.asgi.WSGIDispatch
. PerhapsASGIDispatch
andWSGIDispatch
should be available at the top level.Also, the difference between
remote_addr
for WSGI andclient
for ASGI should be explained or shown as an example, as one is a string and the other a 2-tuple. Or perhaps the API/parameter names should be reconsidered. I know they are meant to mirror the spec names, but maybeclient_ip
("client IP" used in docstring for both). And either a separateclient_port
parameter for both classes or get it automatically in both. Something similar could be said aboutscript_name
androot_path
. Many people reading these docs won't have knowledge of the specs. The different API/parameter names could be a point of confusion. I don't believe the APIs for these classes need to be coupled with the specs. They just need certain information that can be easily and reasonably obtained without any ties to certain terminology. And even if the APIs remain unchanged, they'll probably need extra documentation/explaining unless its expected for users to have to jump into the code.And, for good measure, a couple grammar/typo mistakes that could be good candidates for somebody's Hacktoberfest PRs (maybe mine):
Use a given the client address
-->Use a given client address
.Using httpx as a client, inside test cases.
,Mocking out external services, during tests or in dev/staging environments.
,Mount the WSGI or ASGI application at a subpath, by setting script_name (WSGI) or root_path (ASGI).
andUse a given the client address for requests, by setting remote_addr (WSGI) or client (ASGI).
.The text was updated successfully, but these errors were encountered: