add register

This commit is contained in:
2025-12-02 22:54:27 -03:00
parent e5ac436c5a
commit d461a507f9
6 changed files with 279 additions and 44 deletions

View File

@@ -1,9 +1,11 @@
from typing import Any
from aws_lambda_powertools import Logger, Tracer
from aws_lambda_powertools.event_handler import Response, content_types
from aws_lambda_powertools.event_handler.api_gateway import (
APIGatewayHttpResolver,
)
from aws_lambda_powertools.event_handler.exceptions import ServiceError
from aws_lambda_powertools.logging import correlation_paths
from aws_lambda_powertools.utilities.typing import LambdaContext
@@ -40,6 +42,19 @@ def health():
return {'status': 'available'}
@app.exception_handler(ServiceError)
def exc_error(exc: ServiceError):
return Response(
body={
'type': type(exc).__name__,
'message': str(exc),
},
content_type=content_types.APPLICATION_JSON,
status_code=exc.status_code,
compress=True,
)
@logger.inject_lambda_context(correlation_id_path=correlation_paths.API_GATEWAY_HTTP)
@tracer.capture_lambda_handler
def lambda_handler(event: dict[str, Any], context: LambdaContext) -> dict[str, Any]: