@@ -1489,9 +1489,11 @@ def lambda_handler(event, context):
14891489 ```
14901490 """
14911491
1492+ _proxy_event_type : Enum = ProxyEventType .APIGatewayProxyEvent
1493+
14921494 def __init__ (
14931495 self ,
1494- proxy_type : Enum = ProxyEventType . APIGatewayProxyEvent ,
1496+ proxy_type : Enum | None = None ,
14951497 cors : CORSConfig | None = None ,
14961498 debug : bool | None = None ,
14971499 serializer : Callable [[dict ], str ] | None = None ,
@@ -1524,8 +1526,8 @@ def __init__(
15241526 function to deserialize `str`, `bytes`, `bytearray` containing a JSON document to a Python `dict`,
15251527 by default json.loads when integrating with EventSource data class
15261528 """
1527- self ._proxy_type = proxy_type
15281529 self .dependency_overrides : dict [Callable , Callable ] = {}
1530+ self ._proxy_type = proxy_type or self ._proxy_event_type
15291531 self ._dynamic_routes : list [Route ] = []
15301532 self ._static_routes : list [Route ] = []
15311533 self ._route_keys : list [str ] = []
@@ -2965,28 +2967,7 @@ class APIGatewayRestResolver(ApiGatewayResolver):
29652967 """Amazon API Gateway REST and HTTP API v1 payload resolver"""
29662968
29672969 current_event : APIGatewayProxyEvent
2968-
2969- def __init__ (
2970- self ,
2971- cors : CORSConfig | None = None ,
2972- debug : bool | None = None ,
2973- serializer : Callable [[dict ], str ] | None = None ,
2974- strip_prefixes : list [str | Pattern ] | None = None ,
2975- enable_validation : bool = False ,
2976- response_validation_error_http_code : HTTPStatus | int | None = None ,
2977- json_body_deserializer : Callable [[str ], dict ] | None = None ,
2978- ):
2979- """Amazon API Gateway REST and HTTP API v1 payload resolver"""
2980- super ().__init__ (
2981- ProxyEventType .APIGatewayProxyEvent ,
2982- cors ,
2983- debug ,
2984- serializer ,
2985- strip_prefixes ,
2986- enable_validation ,
2987- response_validation_error_http_code ,
2988- json_body_deserializer = json_body_deserializer ,
2989- )
2970+ _proxy_event_type = ProxyEventType .APIGatewayProxyEvent
29902971
29912972 def _get_base_path (self ) -> str :
29922973 # 3 different scenarios:
@@ -3055,28 +3036,7 @@ class APIGatewayHttpResolver(ApiGatewayResolver):
30553036 """Amazon API Gateway HTTP API v2 payload resolver"""
30563037
30573038 current_event : APIGatewayProxyEventV2
3058-
3059- def __init__ (
3060- self ,
3061- cors : CORSConfig | None = None ,
3062- debug : bool | None = None ,
3063- serializer : Callable [[dict ], str ] | None = None ,
3064- strip_prefixes : list [str | Pattern ] | None = None ,
3065- enable_validation : bool = False ,
3066- response_validation_error_http_code : HTTPStatus | int | None = None ,
3067- json_body_deserializer : Callable [[str ], dict ] | None = None ,
3068- ):
3069- """Amazon API Gateway HTTP API v2 payload resolver"""
3070- super ().__init__ (
3071- ProxyEventType .APIGatewayProxyEventV2 ,
3072- cors ,
3073- debug ,
3074- serializer ,
3075- strip_prefixes ,
3076- enable_validation ,
3077- response_validation_error_http_code ,
3078- json_body_deserializer = json_body_deserializer ,
3079- )
3039+ _proxy_event_type = ProxyEventType .APIGatewayProxyEventV2
30803040
30813041 def _get_base_path (self ) -> str :
30823042 # 3 different scenarios:
@@ -3096,6 +3056,7 @@ class ALBResolver(ApiGatewayResolver):
30963056 """Amazon Application Load Balancer (ALB) resolver"""
30973057
30983058 current_event : ALBEvent
3059+ _proxy_event_type = ProxyEventType .ALBEvent
30993060
31003061 def __init__ (
31013062 self ,
@@ -3135,13 +3096,12 @@ def __init__(
31353096 Enables URL-decoding of query parameters (both keys and values), by default False.
31363097 """
31373098 super ().__init__ (
3138- ProxyEventType .ALBEvent ,
3139- cors ,
3140- debug ,
3141- serializer ,
3142- strip_prefixes ,
3143- enable_validation ,
3144- response_validation_error_http_code ,
3099+ cors = cors ,
3100+ debug = debug ,
3101+ serializer = serializer ,
3102+ strip_prefixes = strip_prefixes ,
3103+ enable_validation = enable_validation ,
3104+ response_validation_error_http_code = response_validation_error_http_code ,
31453105 json_body_deserializer = json_body_deserializer ,
31463106 )
31473107 self .decode_query_parameters = decode_query_parameters
0 commit comments