diff --git a/responder/routes.py b/responder/routes.py index 6ff6535..6e6de67 100644 --- a/responder/routes.py +++ b/responder/routes.py @@ -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)