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
If the root router has an add_static on '/', normalize_path_middleware won't work.
Expected behaviour
A slash to be appended at the end of the url
Actual behaviour
Route /example returns 404 when /example/ is registered.
in normalize_path_middleware at the definition of impl coroutine theres this check: if isinstance(request.match_info.route, SystemRoute):
Normally request.match_info.route is a <SystemRoute: 404>
With add_static it becomes <class 'aiohttp.web_urldispatcher.ResourceRoute'>
So the middleware ignores it.
The problem is in your code, not in add_static or normalize_path_middleware.
The middleware is applied if path is not resolved without slash normalization.
Registering a wildcard static route for root path consmes all possible paths.
Thus, middleware is never processed: all possible paths are going to the static handler.
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].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new
Long story short
If the root router has an add_static on '/', normalize_path_middleware won't work.
Expected behaviour
A slash to be appended at the end of the url
Actual behaviour
Route
/example
returns 404 when/example/
is registered.in
normalize_path_middleware
at the definition ofimpl
coroutine theres this check:if isinstance(request.match_info.route, SystemRoute):
Normally
request.match_info.route
is a<SystemRoute: 404>
With add_static it becomes
<class 'aiohttp.web_urldispatcher.ResourceRoute'>
So the middleware ignores it.
Steps to reproduce
Setup routes like so:
And of course enable
normalize_path_middleware
Try to get
/examples
Your environment
aiohttp 3.0.4 - Server
python 3.6
archlinux @ latest
The text was updated successfully, but these errors were encountered: