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

Add WSGI and ASGI dispatchers #49

Closed
tomchristie opened this issue May 9, 2019 · 2 comments
Closed

Add WSGI and ASGI dispatchers #49

tomchristie opened this issue May 9, 2019 · 2 comments

Comments

@tomchristie
Copy link
Member

tomchristie commented May 9, 2019

We should allow clients to trivially plug into WSGI and ASGI apps.
This will allow:

  • Using httpcore as a test client.
  • Stubbing out third-party-services during tests, rather than making live network requests.

We should support the following:

def hello_world(environ, start_response):
    ...

client = Client(app=hello_world)

And...

async def hello_world(scope, receive, send):
    ...

client = Client(app=hello_world)

This is easy enough for us to do, since we've already got a dispatch=... interface, so we'll want something like this:

if app is not None:
    if is_coroutine(app):
        dispatch = ASGIDispatcher(app)
    else:
        dispatch = WSGIDispatcher(app)

We'll then need ASGIDispatcher and WSGIDispatcher implementations, which implement Dispatcher.send().

@tomchristie
Copy link
Member Author

tomchristie commented May 24, 2019

Related #79 - required for the WSGI case.

@tomchristie
Copy link
Member Author

Done.

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

1 participant