@@ -29,25 +29,27 @@ For example, if your Lambda function is being triggered by an API Gateway proxy
29
29
30
30
=== "app.py"
31
31
32
- ```python hl_lines="1 4"
33
- from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEvent
32
+ ``` python hl_lines="1 4"
33
+ from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEvent
34
34
35
- def lambda_handler(event: dict, context):
36
- event = APIGatewayProxyEvent(event)
37
- if 'helloworld' in event.path and event.http_method == 'GET':
38
- do_something_with(event.body, user)
39
- ```
35
+ def lambda_handler (event : dict , context ):
36
+ event = APIGatewayProxyEvent(event)
37
+ if ' helloworld' in event.path and event.http_method == ' GET' :
38
+ do_something_with(event.body, user)
39
+ ```
40
40
41
- === "app.py using event_source decorator"
41
+ Same example as above, but using the ` event_source ` decorator
42
42
43
- ```python hl_lines="1 3"
44
- from aws_lambda_powertools.utilities.data_classes import event_source, APIGatewayProxyEvent
43
+ === "app.py"
45
44
46
- @event_source(data_class=APIGatewayProxyEvent)
47
- def lambda_handler(event: APIGatewayProxyEvent, context):
48
- if 'helloworld' in event.path and event.http_method == 'GET':
49
- do_something_with(event.body, user)
50
- ```
45
+ ``` python hl_lines="1 3"
46
+ from aws_lambda_powertools.utilities.data_classes import event_source, APIGatewayProxyEvent
47
+
48
+ @event_source (data_class = APIGatewayProxyEvent)
49
+ def lambda_handler (event : APIGatewayProxyEvent, context ):
50
+ if ' helloworld' in event.path and event.http_method == ' GET' :
51
+ do_something_with(event.body, user)
52
+ ```
51
53
52
54
** Autocomplete with self-documented properties and methods**
53
55
@@ -93,10 +95,9 @@ from aws_lambda_powertools.utilities.data_classes import event_source, APIGatewa
93
95
94
96
@event_source (data_class = APIGatewayProxyEvent)
95
97
def lambda_handler (event : APIGatewayProxyEvent, context ):
96
- request_context = event.request_context
97
- identity = request_context.identity
98
-
99
98
if " helloworld" in event.path and event.http_method == " GET" :
99
+ request_context = event.request_context
100
+ identity = request_context.identity
100
101
user = identity.user
101
102
do_something_with(event.json_body, user)
102
103
```
@@ -260,7 +261,6 @@ from aws_lambda_powertools.utilities.data_classes import event_source, CodePipel
260
261
261
262
logger = Logger()
262
263
263
-
264
264
@event_source (data_class = CodePipelineJobEvent)
265
265
def lambda_handler (event , context ):
266
266
""" The Lambda function handler
0 commit comments