Expose ASGI scope on Request object
See original GitHub issueIs your feature request related to a problem? Please describe. I’m trying to write an application framework that works across ASGI compatible server implementations and to do this I’d like to make the ASGI scope available to users. Sanic does not make the scope publicly available though.
Describe the solution you’d like
I’d like the sanic.request.Request
object to provide a scope
attribute which is the current ASGIScope
Additional context
Presently I’m working around this by accessing request.app._asgi_app.transport.scope
Issue Analytics
- State:
- Created a year ago
- Comments:11 (8 by maintainers)
Top Results From Across the Web
ASGI middleware support · Issue #191 - GitHub
This makes perfect sense. I'm already exposing the send and receive functions as asgi.send and asgi.receive , so we can add asgi.scope ....
Read more >Requests - Starlette
Starlette includes a Request class that gives you a nicer interface onto the incoming request, rather than accessing the ASGI scope and receive...
Read more >Working with HTTP requests in ASGI - Encode
The first thing that occurs in any ASGI application is that it is instantiated with a “scope” dictionary, that provides some initial information...
Read more >How to allow a Channels consumer to access session ...
What I want to do now is to create a WebsocketConsumer and access the session from within. I have enabled SessionMiddlewareStack. The problem...
Read more >ASGI Request & Response — Falcon 3.1.1 documentation
Represents a client's HTTP request. Request is not meant to be instantiated directly by responders. scope (dict) – ASGI HTTP connection scope passed...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually… as I think about it more, I do not think that we even need to set it on the
Request
object at all. You should have access to it (I believe):Therefore, it is just a matter of returning that in the
property
and making sure that you are in ASGI.No, not necessarily. ASGI is very important and I hope will continue to be. But we are not getting rid of the internal server either. Being geared specifically for Sanic it has the benefit of being optimized for performance in ways that ASGI servers cannot be.