mirror of
https://github.com/kennethreitz/responder.git
synced 2026-06-05 06:46:14 +00:00
responder now checks routes added via add_route before mounted routes
routes added by `add_route` (including @api.route()) are now checked before routes that were added by api.mount() this especially helps cases for situations where the static route defined by the API class is '/' but the default route is '/' as well
This commit is contained in:
+9
-8
@@ -302,6 +302,15 @@ class Router:
|
||||
path = scope["path"]
|
||||
root_path = scope.get("root_path", "")
|
||||
|
||||
# Check "primary" mounted routes first (before submounted apps)
|
||||
route = self._resolve_route(scope)
|
||||
|
||||
scope["before_requests"] = self.before_requests
|
||||
|
||||
if route is not None:
|
||||
await route(scope, receive, send)
|
||||
return
|
||||
|
||||
# Call into a submounted app, if one exists.
|
||||
for path_prefix, app in self.apps.items():
|
||||
if path.startswith(path_prefix):
|
||||
@@ -315,12 +324,4 @@ class Router:
|
||||
await app(scope, receive, send)
|
||||
return
|
||||
|
||||
route = self._resolve_route(scope)
|
||||
|
||||
scope["before_requests"] = self.before_requests
|
||||
|
||||
if route is not None:
|
||||
await route(scope, receive, send)
|
||||
return
|
||||
|
||||
await self.default_response(scope, receive, send)
|
||||
|
||||
Reference in New Issue
Block a user