Twisted actually has a built in ReverseProxyResource
for this purpose, where the request object is passed to the render
method. It can be extended and modified to do the dynamic routing as you like.
https://twistedmatrix.com/documents/current/api/twisted.web.proxy.ReverseProxyResource.html
The simplest example is here, though you are free to override the resource methods to do the kind of checking you describe.
Site
in this example is a factory that is using the regular HTTP protocol.