aiohttp-cors icon indicating copy to clipboard operation
aiohttp-cors copied to clipboard

`aiohttp-cors` accesses the aiohttp protected `self._routes`

Open bdraco opened this issue 1 year ago • 2 comments

https://github.com/aio-libs/aiohttp-cors/blob/38c6c17bffc805e46baccd7be1b4fd8c69d95dc3/aiohttp_cors/urldispatcher_router_adapter.py#L187

          > `aiohttp-cors` accesses the protected `self._routes` here and relies on being able to add new methods

We could just update that library?

Originally posted by @Dreamsorcerer in https://github.com/aio-libs/aiohttp/issues/9972#issuecomment-2500938152

bdraco avatar Nov 26 '24 20:11 bdraco

We may need to expose a public method in aiohttp for this so this library doesn't need to access the protected one

bdraco avatar Nov 26 '24 20:11 bdraco

Good finding! IIRC a resource can iterate over routes; it works but could be inefficient for the library. Adding resource.routes property that returns a read-only mapping looks like a reasonable addition to me.

asvetlov avatar Nov 26 '24 21:11 asvetlov