You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, this breaks in the newest version, due to the new app object requirement. Unfortunately, since I have to pass the router into the app object during creation, I don't have the app object to properly instantiate the Router.
UrlDispatcher was not designed for extending.
Use it as is -- or implement AbstractRouter from scratch.
Regarding to aiohttp-transmute I suggest another design:
Push transmute context and swagger info into web.Application as app['AIOHTTP_TRANSMUTE_CONTEXT'] for example.
Implement add_transmute_route(app, *args) top-level function for registering route in given application.
Long story short
The new version of aiohttp supports subapps. Which is awesome! Unfortunately, it makes extending UrlDispatcher a little tricky.
I've previously been extending the UrlDispatcher for my extension (I add a way to mount my api methods):
https://github.com/toumorokoshi/aiohttp-transmute/blob/master/aiohttp_transmute/url_dispatcher.py#L8
Example:
https://github.com/toumorokoshi/aiohttp-transmute/blob/master/aiohttp_transmute/tests/example.py#L42
However, this breaks in the newest version, due to the new app object requirement. Unfortunately, since I have to pass the router into the app object during creation, I don't have the app object to properly instantiate the Router.
Expected behaviour
I'm thinking something like this?
Then the code for app would look something like:
Actual behaviour
Unable to instantiate the router properly. I'm passing in app=None right now, but that'll break for subapps.
I'm also open to alternative approaches to what I'm trying to do (mount custom routes, and then keep a dictionary that I use later for documentation).
I can do the PR for this too, if there's agreement on the approach.
Thanks!
The text was updated successfully, but these errors were encountered: