File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed
Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,9 @@ def from_trigger(
101101 if "version" in trigger_event and "requestContext" in trigger_event :
102102 from . import AwsHttpGateway
103103
104- return AwsHttpGateway (trigger_event , trigger_context , ** kwargs )
104+ return AwsHttpGateway (
105+ trigger_event , trigger_context , ** kwargs # type: ignore
106+ )
105107
106108 if "resource" in trigger_event :
107109 from . import AwsApiGateway
Original file line number Diff line number Diff line change @@ -74,11 +74,8 @@ def request(self) -> Request:
7474
7575 if not path :
7676 path = "/"
77- elif self .api_gateway_base_path and self .api_gateway_base_path != "/" :
78- if not self .api_gateway_base_path .startswith ("/" ):
79- self .api_gateway_base_path = f"/{ self .api_gateway_base_path } "
80- if path .startswith (self .api_gateway_base_path ):
81- path = path [len (self .api_gateway_base_path ) :]
77+ else :
78+ path = self ._strip_base_path (path )
8279
8380 return Request (
8481 method = http_method ,
@@ -93,6 +90,14 @@ def request(self) -> Request:
9390 event_type = self .TYPE ,
9491 )
9592
93+ def _strip_base_path (self , path : str ) -> str :
94+ if self .api_gateway_base_path and self .api_gateway_base_path != "/" :
95+ if not self .api_gateway_base_path .startswith ("/" ):
96+ self .api_gateway_base_path = f"/{ self .api_gateway_base_path } "
97+ if path .startswith (self .api_gateway_base_path ):
98+ path = path [len (self .api_gateway_base_path ) :]
99+ return path
100+
96101 @property
97102 def body (self ) -> bytes :
98103 body = self .trigger_event .get ("body" , b"" ) or b""
Original file line number Diff line number Diff line change 22import urllib .parse
33from typing import Dict , Any
44
5- from .abstract_handler import AbstractHandler
5+ from . import AwsApiGateway
66from .. import Response , Request
77
88
9- class AwsHttpGateway (AbstractHandler ):
9+ class AwsHttpGateway (AwsApiGateway ):
1010 """
1111 Handles AWS HTTP Gateway events (v1.0 and v2.0), transforming them into ASGI Scope
1212 and handling responses
@@ -86,6 +86,8 @@ def request(self) -> Request:
8686
8787 if not path :
8888 path = "/"
89+ else :
90+ path = self ._strip_base_path (path )
8991
9092 return Request (
9193 method = http_method ,
You can’t perform that action at this time.
0 commit comments