Skip to content

Commit

Permalink
Revert api_gateway_base_path name change to match previous releases a…
Browse files Browse the repository at this point in the history
…nd docs (#192)
  • Loading branch information
jordaneremieff authored Jul 16, 2021
1 parent 83e80a6 commit c680fb3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions mangum/handlers/aws_api_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/test_aws_api_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 == {
Expand All @@ -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!",
Expand Down

0 comments on commit c680fb3

Please sign in to comment.