@@ -1460,9 +1460,11 @@ def lambda_handler(event, context):
14601460 ```
14611461 """
14621462
1463+ _proxy_event_type : Enum = ProxyEventType .APIGatewayProxyEvent
1464+
14631465 def __init__ (
14641466 self ,
1465- proxy_type : Enum = ProxyEventType . APIGatewayProxyEvent ,
1467+ proxy_type : Enum | None = None ,
14661468 cors : CORSConfig | None = None ,
14671469 debug : bool | None = None ,
14681470 serializer : Callable [[dict ], str ] | None = None ,
@@ -1495,7 +1497,7 @@ def __init__(
14951497 function to deserialize `str`, `bytes`, `bytearray` containing a JSON document to a Python `dict`,
14961498 by default json.loads when integrating with EventSource data class
14971499 """
1498- self ._proxy_type = proxy_type
1500+ self ._proxy_type = proxy_type or self . _proxy_event_type
14991501 self ._dynamic_routes : list [Route ] = []
15001502 self ._static_routes : list [Route ] = []
15011503 self ._route_keys : list [str ] = []
@@ -2935,28 +2937,7 @@ class APIGatewayRestResolver(ApiGatewayResolver):
29352937 """Amazon API Gateway REST and HTTP API v1 payload resolver"""
29362938
29372939 current_event : APIGatewayProxyEvent
2938-
2939- def __init__ (
2940- self ,
2941- cors : CORSConfig | None = None ,
2942- debug : bool | None = None ,
2943- serializer : Callable [[dict ], str ] | None = None ,
2944- strip_prefixes : list [str | Pattern ] | None = None ,
2945- enable_validation : bool = False ,
2946- response_validation_error_http_code : HTTPStatus | int | None = None ,
2947- json_body_deserializer : Callable [[str ], dict ] | None = None ,
2948- ):
2949- """Amazon API Gateway REST and HTTP API v1 payload resolver"""
2950- super ().__init__ (
2951- ProxyEventType .APIGatewayProxyEvent ,
2952- cors ,
2953- debug ,
2954- serializer ,
2955- strip_prefixes ,
2956- enable_validation ,
2957- response_validation_error_http_code ,
2958- json_body_deserializer = json_body_deserializer ,
2959- )
2940+ _proxy_event_type = ProxyEventType .APIGatewayProxyEvent
29602941
29612942 def _get_base_path (self ) -> str :
29622943 # 3 different scenarios:
@@ -3025,28 +3006,7 @@ class APIGatewayHttpResolver(ApiGatewayResolver):
30253006 """Amazon API Gateway HTTP API v2 payload resolver"""
30263007
30273008 current_event : APIGatewayProxyEventV2
3028-
3029- def __init__ (
3030- self ,
3031- cors : CORSConfig | None = None ,
3032- debug : bool | None = None ,
3033- serializer : Callable [[dict ], str ] | None = None ,
3034- strip_prefixes : list [str | Pattern ] | None = None ,
3035- enable_validation : bool = False ,
3036- response_validation_error_http_code : HTTPStatus | int | None = None ,
3037- json_body_deserializer : Callable [[str ], dict ] | None = None ,
3038- ):
3039- """Amazon API Gateway HTTP API v2 payload resolver"""
3040- super ().__init__ (
3041- ProxyEventType .APIGatewayProxyEventV2 ,
3042- cors ,
3043- debug ,
3044- serializer ,
3045- strip_prefixes ,
3046- enable_validation ,
3047- response_validation_error_http_code ,
3048- json_body_deserializer = json_body_deserializer ,
3049- )
3009+ _proxy_event_type = ProxyEventType .APIGatewayProxyEventV2
30503010
30513011 def _get_base_path (self ) -> str :
30523012 # 3 different scenarios:
@@ -3066,6 +3026,7 @@ class ALBResolver(ApiGatewayResolver):
30663026 """Amazon Application Load Balancer (ALB) resolver"""
30673027
30683028 current_event : ALBEvent
3029+ _proxy_event_type = ProxyEventType .ALBEvent
30693030
30703031 def __init__ (
30713032 self ,
@@ -3105,13 +3066,12 @@ def __init__(
31053066 Enables URL-decoding of query parameters (both keys and values), by default False.
31063067 """
31073068 super ().__init__ (
3108- ProxyEventType .ALBEvent ,
3109- cors ,
3110- debug ,
3111- serializer ,
3112- strip_prefixes ,
3113- enable_validation ,
3114- response_validation_error_http_code ,
3069+ cors = cors ,
3070+ debug = debug ,
3071+ serializer = serializer ,
3072+ strip_prefixes = strip_prefixes ,
3073+ enable_validation = enable_validation ,
3074+ response_validation_error_http_code = response_validation_error_http_code ,
31153075 json_body_deserializer = json_body_deserializer ,
31163076 )
31173077 self .decode_query_parameters = decode_query_parameters
0 commit comments