Skip to content

Commit e492769

Browse files
author
Michael Brewer
committed
chore: better docs
1 parent 008afad commit e492769

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

aws_lambda_powertools/event_handler/api_gateway.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ProxyEventType(Enum):
3737
ALBEvent = "ALBEvent"
3838

3939

40-
class CORSConfig(object):
40+
class CORSConfig:
4141
"""CORS Config
4242
4343
Examples
@@ -280,7 +280,8 @@ def __init__(
280280
serializer : Callable, optional
281281
function to serialize `obj` to a JSON formatted `str`, by default json.dumps
282282
strip_prefixes: List[str], optional
283-
optional list of prefixes to be removed from the path before doing the routing
283+
optional list of prefixes to be removed from the request path before doing the routing. This is often used
284+
with api gateways with multiple custom mappings.
284285
"""
285286
self._proxy_type = proxy_type
286287
self._routes: List[Route] = []

tests/functional/event_handler/test_api_gateway.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -774,16 +774,20 @@ def get_color() -> Dict:
774774
@pytest.mark.parametrize(
775775
"path",
776776
[
777-
pytest.param("/pay/foo", id="prefix matches path"),
778-
pytest.param("/payment/foo", id="prefix matches path"),
779-
pytest.param("/foo", id="prefix does not match path"),
777+
pytest.param("/pay/foo", id="path matched pay prefix"),
778+
pytest.param("/payment/foo", id="path matched payment prefix"),
779+
pytest.param("/foo", id="path does not start with any of the prefixes"),
780780
],
781781
)
782782
def test_remove_prefix(path: str):
783-
# GIVEN a configured prefix of `/pay`
784-
# AND events paths `/pay/foo` or `/foo`
783+
# GIVEN events paths `/pay/foo`, `/payment/foo` or `/foo`
784+
# AND a configured strip_prefixes of `/pay` and `/payment`
785785
app = ApiGatewayResolver(strip_prefixes=["/pay", "/payment"])
786786

787+
@app.get("/pay/foo")
788+
def pay_foo():
789+
raise ValueError("should not be matching")
790+
787791
@app.get("/foo")
788792
def foo():
789793
...

0 commit comments

Comments
 (0)