diff --git a/docs/core/event_handler/api_gateway.md b/docs/core/event_handler/api_gateway.md index 257c17ec13a..4e4e935f699 100644 --- a/docs/core/event_handler/api_gateway.md +++ b/docs/core/event_handler/api_gateway.md @@ -883,8 +883,10 @@ Each endpoint will be it's own Lambda function that is configured as a [Lambda i --8<-- "examples/event_handler_rest/sam/micro_function_template.yaml" ``` + ???+ note - You can see some of the downsides in this example such as some code reuse. If set up with proper build tooling, the `User` class could be shared across functions. This could be accomplished by packaging shared code as a Lambda Layer. + You can see some of the downsides in this example such as some code reuse. If set up with proper build tooling, the `User` class could be shared across functions. This could be accomplished by packaging shared code as a [Lambda Layer](https://docs.aws.amazon.com/lambda/latest/dg/chapter-layers.html){target="_blank"} or [Pants](https://www.pantsbuild.org/docs/awslambda-python){target="_blank" rel="nofollow"}. + ## Testing your code diff --git a/examples/event_handler_rest/src/micro_function_user_by_id_route.py b/examples/event_handler_rest/src/micro_function_user_by_id_route.py index 4f6e7add85a..f47464732a1 100644 --- a/examples/event_handler_rest/src/micro_function_user_by_id_route.py +++ b/examples/event_handler_rest/src/micro_function_user_by_id_route.py @@ -1,6 +1,7 @@ import json from dataclasses import dataclass from http import HTTPStatus +from typing import Union from aws_lambda_powertools import Logger from aws_lambda_powertools.event_handler import APIGatewayRestResolver, Response @@ -43,7 +44,7 @@ def get_user_by_id(user_id: str) -> Union[User, None]: email=str(user_data["email"]), active=bool(user_data["active"]), ) - + return None