Currently, we basically make all the interfaces look a bit like a WSGI request, then http.Request can use .environ and stuff to find information like IP address and host.
I think it would be better to have an InterfaceRequest wrapper that would take the raw request and then the interface could implement the supported methods, and then http.Request would be instantiated like this:
create an interface request class that can handle bridging between the interface (uwsgi, asgi) and the request object. So basically, the interface would create an InterfaceRequest class and pass that to Request, then Request would use InterfaceRequest for things like .ip and .scheme
So the big question is, why would we do this over just having these things set directly on http.request in the interface's create_request method like we kind of do now? This solution would make it so the code is run on demand instead of all ran in the create_request method. Likewise, it would provide a standard template for what needs to be implemented, right now to add a new interface I usually look at what a previous interface's create_request method is doing.
Biggest annoyance would be all the tests that just create a request object, I'd need to change all those to take the InterfaceRequest instance, and there are a lot of tests.
Currently, we basically make all the interfaces look a bit like a WSGI request, then
http.Request
can use.environ
and stuff to find information like IP address and host.I think it would be better to have an
InterfaceRequest
wrapper that would take the raw request and then the interface could implement the supported methods, and thenhttp.Request
would be instantiated like this:I think the class would be something like:
This was my original note:
So the big question is, why would we do this over just having these things set directly on
http.request
in the interface'screate_request
method like we kind of do now? This solution would make it so the code is run on demand instead of all ran in thecreate_request
method. Likewise, it would provide a standard template for what needs to be implemented, right now to add a new interface I usually look at what a previous interface'screate_request
method is doing.Biggest annoyance would be all the tests that just create a request object, I'd need to change all those to take the
InterfaceRequest
instance, and there are a lot of tests.