File tree 2 files changed +12
-7
lines changed
aws_lambda_powertools/event_handler
tests/functional/event_handler
2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class ProxyEventType(Enum):
37
37
ALBEvent = "ALBEvent"
38
38
39
39
40
- class CORSConfig ( object ) :
40
+ class CORSConfig :
41
41
"""CORS Config
42
42
43
43
Examples
@@ -280,7 +280,8 @@ def __init__(
280
280
serializer : Callable, optional
281
281
function to serialize `obj` to a JSON formatted `str`, by default json.dumps
282
282
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.
284
285
"""
285
286
self ._proxy_type = proxy_type
286
287
self ._routes : List [Route ] = []
Original file line number Diff line number Diff line change @@ -774,16 +774,20 @@ def get_color() -> Dict:
774
774
@pytest .mark .parametrize (
775
775
"path" ,
776
776
[
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 " ),
780
780
],
781
781
)
782
782
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 `
785
785
app = ApiGatewayResolver (strip_prefixes = ["/pay" , "/payment" ])
786
786
787
+ @app .get ("/pay/foo" )
788
+ def pay_foo ():
789
+ raise ValueError ("should not be matching" )
790
+
787
791
@app .get ("/foo" )
788
792
def foo ():
789
793
...
You can’t perform that action at this time.
0 commit comments