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

Defer ASGI #149

Open
ZeroIntensity opened this issue Feb 5, 2024 · 1 comment
Open

Defer ASGI #149

ZeroIntensity opened this issue Feb 5, 2024 · 1 comment
Labels
api This has to do with the Python API (view) c api This has to do with the C API (_view) delayed Delayed due to another issue feature New feature
Milestone

Comments

@ZeroIntensity
Copy link
Owner

Feature description

For compatibility with ASGI toolkits like Starlette, view.py should make it possible to defer the ASGI scope, receive, and send. This will allow someone to for example, mount an existing Starlette app against a view.py server, which very much aligns with batteries-detachable.

Feature example API

from starlette.responses import PlainTextResponse
from view import new_app

app = new_app()

@app.defer("/prefix")
async def starlette_app(scope, receive, send):
    assert scope['type'] == 'http'
    response = PlainTextResponse('Hello, world!')
    await response(scope, receive, send)

app.run()

Anything else?

This will be waiting on #82, as prefixing will require path parameters.

@ZeroIntensity ZeroIntensity added feature New feature c api This has to do with the C API (_view) api This has to do with the Python API (view) delayed Delayed due to another issue labels Feb 5, 2024
@ZeroIntensity ZeroIntensity added this to the Beta milestone May 7, 2024
@ZeroIntensity
Copy link
Owner Author

Maybe this could some with some WSGI hook utility as well? I don't know that much about WSGI, but theoretically it should be possible to convert ASGI objects into their WSGI counterparts. This would be incredibly useful for say, mounting a Django app on top of a view.py app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api This has to do with the Python API (view) c api This has to do with the C API (_view) delayed Delayed due to another issue feature New feature
Projects
None yet
Development

No branches or pull requests

1 participant