@@ -47,9 +47,9 @@ class CORSConfig:
47
47
Simple cors example using the default permissive cors, not this should only be used during early prototyping
48
48
49
49
```python
50
- from aws_lambda_powertools.event_handler.api_gateway import ApiGatewayResolver
50
+ from aws_lambda_powertools.event_handler import APIGatewayRestResolver
51
51
52
- app = ApiGatewayResolver ()
52
+ app = APIGatewayRestResolver ()
53
53
54
54
@app.get("/my/path", cors=True)
55
55
def with_cors():
@@ -61,7 +61,7 @@ def with_cors():
61
61
62
62
```python
63
63
from aws_lambda_powertools.event_handler.api_gateway import (
64
- ApiGatewayResolver , CORSConfig
64
+ APIGatewayRestResolver , CORSConfig
65
65
)
66
66
67
67
cors_config = CORSConfig(
@@ -71,7 +71,7 @@ def with_cors():
71
71
max_age=100,
72
72
allow_credentials=True,
73
73
)
74
- app = ApiGatewayResolver (cors=cors_config)
74
+ app = APIGatewayRestResolver (cors=cors_config)
75
75
76
76
@app.get("/my/path")
77
77
def with_cors():
@@ -252,10 +252,10 @@ def get(self, rule: str, cors: Optional[bool] = None, compress: bool = False, ca
252
252
253
253
```python
254
254
from aws_lambda_powertools import Tracer
255
- from aws_lambda_powertools.event_handler.api_gateway import ApiGatewayResolver
255
+ from aws_lambda_powertools.event_handler import APIGatewayRestResolver
256
256
257
257
tracer = Tracer()
258
- app = ApiGatewayResolver ()
258
+ app = APIGatewayRestResolver ()
259
259
260
260
@app.get("/get-call")
261
261
def simple_get():
@@ -277,10 +277,10 @@ def post(self, rule: str, cors: Optional[bool] = None, compress: bool = False, c
277
277
278
278
```python
279
279
from aws_lambda_powertools import Tracer
280
- from aws_lambda_powertools.event_handler.api_gateway import ApiGatewayResolver
280
+ from aws_lambda_powertools.event_handler import APIGatewayRestResolver
281
281
282
282
tracer = Tracer()
283
- app = ApiGatewayResolver ()
283
+ app = APIGatewayRestResolver ()
284
284
285
285
@app.post("/post-call")
286
286
def simple_post():
@@ -303,10 +303,10 @@ def put(self, rule: str, cors: Optional[bool] = None, compress: bool = False, ca
303
303
304
304
```python
305
305
from aws_lambda_powertools import Tracer
306
- from aws_lambda_powertools.event_handler.api_gateway import ApiGatewayResolver
306
+ from aws_lambda_powertools.event_handler import APIGatewayRestResolver
307
307
308
308
tracer = Tracer()
309
- app = ApiGatewayResolver ()
309
+ app = APIGatewayRestResolver ()
310
310
311
311
@app.put("/put-call")
312
312
def simple_put():
@@ -331,10 +331,10 @@ def delete(
331
331
332
332
```python
333
333
from aws_lambda_powertools import Tracer
334
- from aws_lambda_powertools.event_handler.api_gateway import ApiGatewayResolver
334
+ from aws_lambda_powertools.event_handler import APIGatewayRestResolver
335
335
336
336
tracer = Tracer()
337
- app = ApiGatewayResolver ()
337
+ app = APIGatewayRestResolver ()
338
338
339
339
@app.delete("/delete-call")
340
340
def simple_delete():
@@ -358,10 +358,10 @@ def patch(
358
358
359
359
```python
360
360
from aws_lambda_powertools import Tracer
361
- from aws_lambda_powertools.event_handler.api_gateway import ApiGatewayResolver
361
+ from aws_lambda_powertools.event_handler import APIGatewayRestResolver
362
362
363
363
tracer = Tracer()
364
- app = ApiGatewayResolver ()
364
+ app = APIGatewayRestResolver ()
365
365
366
366
@app.patch("/patch-call")
367
367
def simple_patch():
@@ -387,10 +387,10 @@ class ApiGatewayResolver(BaseRouter):
387
387
388
388
```python
389
389
from aws_lambda_powertools import Tracer
390
- from aws_lambda_powertools.event_handler.api_gateway import ApiGatewayResolver
390
+ from aws_lambda_powertools.event_handler import APIGatewayRestResolver
391
391
392
392
tracer = Tracer()
393
- app = ApiGatewayResolver ()
393
+ app = APIGatewayRestResolver ()
394
394
395
395
@app.get("/get-call")
396
396
def simple_get():
@@ -731,3 +731,45 @@ def register_route(func: Callable):
731
731
self ._routes [(rule , methods , cors , compress , cache_control )] = func
732
732
733
733
return register_route
734
+
735
+
736
+ class APIGatewayRestResolver (ApiGatewayResolver ):
737
+ current_event : APIGatewayProxyEvent
738
+
739
+ def __init__ (
740
+ self ,
741
+ cors : Optional [CORSConfig ] = None ,
742
+ debug : Optional [bool ] = None ,
743
+ serializer : Optional [Callable [[Dict ], str ]] = None ,
744
+ strip_prefixes : Optional [List [str ]] = None ,
745
+ ):
746
+ """Amazon API Gateway REST and HTTP API v1 payload resolver"""
747
+ super ().__init__ (ProxyEventType .APIGatewayProxyEvent , cors , debug , serializer , strip_prefixes )
748
+
749
+
750
+ class APIGatewayHttpResolver (ApiGatewayResolver ):
751
+ current_event : APIGatewayProxyEventV2
752
+
753
+ def __init__ (
754
+ self ,
755
+ cors : Optional [CORSConfig ] = None ,
756
+ debug : Optional [bool ] = None ,
757
+ serializer : Optional [Callable [[Dict ], str ]] = None ,
758
+ strip_prefixes : Optional [List [str ]] = None ,
759
+ ):
760
+ """Amazon API Gateway HTTP API v2 payload resolver"""
761
+ super ().__init__ (ProxyEventType .APIGatewayProxyEventV2 , cors , debug , serializer , strip_prefixes )
762
+
763
+
764
+ class ALBResolver (ApiGatewayResolver ):
765
+ current_event : ALBEvent
766
+
767
+ def __init__ (
768
+ self ,
769
+ cors : Optional [CORSConfig ] = None ,
770
+ debug : Optional [bool ] = None ,
771
+ serializer : Optional [Callable [[Dict ], str ]] = None ,
772
+ strip_prefixes : Optional [List [str ]] = None ,
773
+ ):
774
+ """Amazon Application Load Balancer (ALB) resolver"""
775
+ super ().__init__ (ProxyEventType .ALBEvent , cors , debug , serializer , strip_prefixes )
0 commit comments