Skip to content

Commit

Permalink
Merge pull request #406 from daphil19/master
Browse files Browse the repository at this point in the history
fix issues related to using `static=true` in `api.add_route()` and `static_route` in `responder.API()`
  • Loading branch information
taoufik07 authored Nov 19, 2019
2 parents a80df80 + ead213a commit 6761e3b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion responder/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ async def _static_response(self, req, resp):
index = (self.static_dir / "index.html").resolve()
if os.path.exists(index):
with open(index, "r") as f:
resp.html = "Hello world !"
resp.html = f.read()
else:
resp.status_code = status_codes.HTTP_404
resp.text = "Not found."
Expand Down
17 changes: 9 additions & 8 deletions responder/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,15 @@ async def __call__(self, scope, receive, send):
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):
Expand All @@ -315,12 +324,4 @@ async def __call__(self, scope, receive, send):
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)

0 comments on commit 6761e3b

Please sign in to comment.