Skip to content

Commit

Permalink
chore: better docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Brewer committed Aug 19, 2021
1 parent 008afad commit e492769
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions aws_lambda_powertools/event_handler/api_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ProxyEventType(Enum):
ALBEvent = "ALBEvent"


class CORSConfig(object):
class CORSConfig:
"""CORS Config
Examples
Expand Down Expand Up @@ -280,7 +280,8 @@ def __init__(
serializer : Callable, optional
function to serialize `obj` to a JSON formatted `str`, by default json.dumps
strip_prefixes: List[str], optional
optional list of prefixes to be removed from the path before doing the routing
optional list of prefixes to be removed from the request path before doing the routing. This is often used
with api gateways with multiple custom mappings.
"""
self._proxy_type = proxy_type
self._routes: List[Route] = []
Expand Down
14 changes: 9 additions & 5 deletions tests/functional/event_handler/test_api_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,16 +774,20 @@ def get_color() -> Dict:
@pytest.mark.parametrize(
"path",
[
pytest.param("/pay/foo", id="prefix matches path"),
pytest.param("/payment/foo", id="prefix matches path"),
pytest.param("/foo", id="prefix does not match path"),
pytest.param("/pay/foo", id="path matched pay prefix"),
pytest.param("/payment/foo", id="path matched payment prefix"),
pytest.param("/foo", id="path does not start with any of the prefixes"),
],
)
def test_remove_prefix(path: str):
# GIVEN a configured prefix of `/pay`
# AND events paths `/pay/foo` or `/foo`
# GIVEN events paths `/pay/foo`, `/payment/foo` or `/foo`
# AND a configured strip_prefixes of `/pay` and `/payment`
app = ApiGatewayResolver(strip_prefixes=["/pay", "/payment"])

@app.get("/pay/foo")
def pay_foo():
raise ValueError("should not be matching")

@app.get("/foo")
def foo():
...
Expand Down

0 comments on commit e492769

Please sign in to comment.