|
3 | 3 | import base64 |
4 | 4 | import json |
5 | 5 | import logging |
6 | | -import inspect |
7 | 6 | import re |
8 | 7 | import traceback |
9 | 8 | import warnings |
@@ -1475,64 +1474,7 @@ def _registered_api_adapter( |
1475 | 1474 |
|
1476 | 1475 | return app._to_response(next_middleware(**route_args)) |
1477 | 1476 |
|
1478 | | -async def _registered_api_adapter_async( |
1479 | | - app: ApiGatewayResolver, |
1480 | | - next_middleware: Callable[..., Any], |
1481 | | -) -> dict | tuple | Response | BedrockResponse: |
1482 | | - """ |
1483 | | - Async version of _registered_api_adapter. |
1484 | | -
|
1485 | | - Detects if the route handler is a coroutine and awaits it. |
1486 | | - _to_response() stays sync (CPU-bound — no async benefit). |
1487 | | -
|
1488 | | - **IMPORTANT: This is an internal building block only. |
1489 | | - Nothing calls it in the resolve chain yet. It will be used |
1490 | | - by resolve_async() (see issue #8137). |
1491 | | -
|
1492 | | - Parameters |
1493 | | - ---------- |
1494 | | - app: ApiGatewayResolver |
1495 | | - The API Gateway resolver |
1496 | | - next_middleware: Callable[..., Any] |
1497 | | - The function to handle the API |
1498 | | -
|
1499 | | - Returns |
1500 | | - ------- |
1501 | | - Response |
1502 | | - The API Response Object |
1503 | | - """ |
1504 | | - route_args: dict = app.context.get("_route_args", {}) |
1505 | | - logger.debug(f"Calling async API Route Handler: {route_args}") |
1506 | | - |
1507 | | - # Inject a Request object when the handler declares a parameter typed as Request. |
1508 | | - # Lookup is cached on the Route object to avoid repeated signature inspection. |
1509 | | - route: Route | None = app.context.get("_route") |
1510 | | - if route is not None: |
1511 | | - if not route.request_param_name_checked: |
1512 | | - route.request_param_name = _find_request_param_name(next_middleware) |
1513 | | - route.request_param_name_checked = True |
1514 | | - if route.request_param_name: |
1515 | | - route_args = {**route_args, route.request_param_name: app.request} |
1516 | | - |
1517 | | - # Resolve Depends() parameters (same as sync version) |
1518 | | - if route.has_dependencies: |
1519 | | - from aws_lambda_powertools.event_handler.depends import build_dependency_tree, solve_dependencies |
1520 | | - |
1521 | | - dep_values = solve_dependencies( |
1522 | | - dependant=build_dependency_tree(route.func), |
1523 | | - request=app.request, |
1524 | | - dependency_overrides=app.dependency_overrides or None, |
1525 | | - ) |
1526 | | - route_args.update(dep_values) |
1527 | | - |
1528 | | - # Call handler — detect if result is a coroutine and await it |
1529 | | - result = next_middleware(**route_args) |
1530 | | - if inspect.iscoroutine(result): |
1531 | | - result = await result |
1532 | 1477 |
|
1533 | | - # _to_response is CPU-bound, stays sync |
1534 | | - return app._to_response(result) |
1535 | | - |
1536 | 1478 | class ApiGatewayResolver(BaseRouter): |
1537 | 1479 | """API Gateway, VPC Lattice, Bedrock and ALB proxy resolver |
1538 | 1480 |
|
|
0 commit comments