Apply path_from_header to entire scope, refs #712

path-from-header
Simon Willison 2020-03-25 21:03:17 -07:00
rodzic fb0460dd0b
commit 0f217b5e8d
1 zmienionych plików z 2 dodań i 5 usunięć

Wyświetl plik

@ -742,13 +742,10 @@ class DatasetteRouter(AsgiRouter):
async def __call__(self, scope, receive, send):
path_from_header = self.ds.config("path_from_header")
path = scope["path"]
raw_path = scope.get("raw_path")
if path_from_header:
raw_path = dict(scope["headers"])[path_from_header.encode("utf8")]
if raw_path:
path = raw_path.decode("ascii")
return await self.route_path(scope, receive, send, path)
scope = dict(scope, raw_path=raw_path)
return await super().__call__(scope, receive, send)
async def route_path(self, scope, receive, send, path):
# Strip off base_url if present before routing