From c680fb3ae1d43c56c03af6fe64b41aa281b5f5fb Mon Sep 17 00:00:00 2001 From: Jordan Eremieff <1376648+jordaneremieff@users.noreply.github.com> Date: Sat, 17 Jul 2021 03:46:17 +1000 Subject: [PATCH] Revert api_gateway_base_path name change to match previous releases and docs (#192) --- mangum/handlers/aws_api_gateway.py | 14 +++++++------- tests/handlers/test_aws_api_gateway.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mangum/handlers/aws_api_gateway.py b/mangum/handlers/aws_api_gateway.py index 2e239d44..f6e05ae6 100644 --- a/mangum/handlers/aws_api_gateway.py +++ b/mangum/handlers/aws_api_gateway.py @@ -24,11 +24,11 @@ def __init__( self, trigger_event: Dict[str, Any], trigger_context: "LambdaContext", - base_path: str = "/", + api_gateway_base_path: str = "/", **kwargs: Dict[str, Any], # type: ignore ): super().__init__(trigger_event, trigger_context, **kwargs) - self.base_path = base_path + self.api_gateway_base_path = api_gateway_base_path @property def request(self) -> Request: @@ -74,11 +74,11 @@ def request(self) -> Request: if not path: path = "/" - elif self.base_path and self.base_path != "/": - if not self.base_path.startswith("/"): - self.base_path = f"/{self.base_path}" - if path.startswith(self.base_path): - path = path[len(self.base_path) :] + elif self.api_gateway_base_path and self.api_gateway_base_path != "/": + if not self.api_gateway_base_path.startswith("/"): + self.api_gateway_base_path = f"/{self.api_gateway_base_path}" + if path.startswith(self.api_gateway_base_path): + path = path[len(self.api_gateway_base_path) :] return Request( method=http_method, diff --git a/tests/handlers/test_aws_api_gateway.py b/tests/handlers/test_aws_api_gateway.py index e35bf4e8..1ce16211 100644 --- a/tests/handlers/test_aws_api_gateway.py +++ b/tests/handlers/test_aws_api_gateway.py @@ -266,7 +266,7 @@ async def app(scope, receive, send): ) await send({"type": "http.response.body", "body": b"Hello world!"}) - handler = Mangum(app, lifespan="off", base_path=None) + handler = Mangum(app, lifespan="off", api_gateway_base_path=None) response = handler(event, {}) assert response == { @@ -292,7 +292,7 @@ async def app(scope, receive, send): await send({"type": "http.response.body", "body": b"Hello world!"}) api_gateway_base_path = "test" - handler = Mangum(app, lifespan="off", base_path=api_gateway_base_path) + handler = Mangum(app, lifespan="off", api_gateway_base_path=api_gateway_base_path) response = handler(event, {}) assert response == { "body": "Hello world!",