We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
According to http://aiohttp.readthedocs.io/en/stable/web.html#nested-applications, [I]f URL is '/admin/something' middlewares from [main application] are applied first and [sub application] middlewares are the next in the call chain.
[I]f URL is '/admin/something' middlewares from [main application] are applied first and [sub application] middlewares are the next in the call chain.
It turns out it's actually the other way.
Run this code saved as foo.py:
#!/usr/bin/python3 -tt import aiohttp import aiohttp.web async def middleware1(app, next_handler): async def handler(request): print("middleware1") return await next_handler(request) return handler async def middleware2(app, next_handler): async def handler(request): print("middleware2") return await next_handler(request) return handler async def middleware3(app, next_handler): async def handler(request): print("middleware3") return await next_handler(request) return handler app = aiohttp.web.Application( middlewares=[middleware1]) subapp1 = aiohttp.web.Application(middlewares=[middleware2]) app.add_subapp("/foo", subapp1) subapp2 = aiohttp.web.Application(middlewares=[middleware3]) subapp1.add_subapp("/foo/bar", subapp2) aiohttp.web.run_app(app, host='127.0.0.1', port=4096)
And the run wget http://127.0.0.1:4096/foo/bar.
wget http://127.0.0.1:4096/foo/bar
$ python3 foo.py ======== Running on http://127.0.0.1:4096 ======== (Press CTRL+C to quit) middleware3 middleware2 middleware1
$ python3 foo.py ======== Running on http://127.0.0.1:4096 ======== (Press CTRL+C to quit) middleware1 middleware2 middleware3
Ubuntu Xenial (python 3.5.2) with aiohttp 2.0.7
The text was updated successfully, but these errors were encountered:
CHANGES.rst: fixing aio-libs#1853
1954e99
CHANGES.rst: fix for aio-libs#1853
a9b8cf7
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that new issue.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Long story short
According to http://aiohttp.readthedocs.io/en/stable/web.html#nested-applications,
[I]f URL is '/admin/something' middlewares from [main application] are applied first and [sub application] middlewares are the next in the call chain.
It turns out it's actually the other way.
Steps to reproduce
Run this code saved as foo.py:
And the run
wget http://127.0.0.1:4096/foo/bar
.Current Result:
Expected output:
Your environment
Ubuntu Xenial (python 3.5.2) with aiohttp 2.0.7
The text was updated successfully, but these errors were encountered: