Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2def841

Browse files
committedJan 11, 2023
docs(apigw) - adding full example
1 parent 482263d commit 2def841

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed
 

‎docs/core/event_handler/api_gateway.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ You can use specialized router classes according to the type of event that you a
470470
| ALBRouter | ALBResolver | ALBEvent |
471471
| LambdaFunctionUrlRouter | LambdaFunctionUrlResolver | LambdaFunctionUrlEvent |
472472

473-
```python hl_lines="3 9"
473+
```python hl_lines="1 5 9"
474474
--8<-- "examples/event_handler_rest/src/split_route_specialized_router.py"
475475
```
476476

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1+
from aws_lambda_powertools.event_handler import APIGatewayRestResolver
12
from aws_lambda_powertools.event_handler.router import APIGatewayRouter
23

4+
app = APIGatewayRestResolver()
35
router = APIGatewayRouter()
46

57

68
@router.get("/me")
79
def get_self():
810
# router.current_event is a APIGatewayProxyEvent
9-
principal_id = router.current_event.request_context.authorizer.principal_id
11+
account_id = router.current_event.request_context.account_id
1012

11-
return {"principal_id": principal_id}
13+
return {"account_id": account_id}
14+
15+
16+
app.include_router(router)
17+
18+
19+
def lambda_handler(event, context):
20+
return app.resolve(event, context)

0 commit comments

Comments
 (0)
Please sign in to comment.