Skip to content

Commit ca498b5

Browse files
committed
Merge branch 'handle_request_path' of github.com:lfpratik/serverless-wsgi into lfpratik-handle_request_path
2 parents 600b4af + 2ad6b0f commit ca498b5

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

serverless_wsgi.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ def generate_response(response, event):
162162
return returndict
163163

164164

165+
def get_path(path):
166+
if '?' in path:
167+
path = path.split('?')[0]
168+
return path
169+
170+
165171
def handle_request(app, event, context):
166172
if event.get("source") in ["aws.events", "serverless-plugin-warmup"]:
167173
print("Lambda warming event received, skipping handler")
@@ -191,7 +197,7 @@ def handle_payload_v1(app, event, context):
191197
# If a user is using a custom domain on API Gateway, they may have a base
192198
# path in their URL. This allows us to strip it out via an optional
193199
# environment variable.
194-
path_info = event["path"]
200+
path_info = get_path(event["path"])
195201
base_path = os.environ.get("API_GATEWAY_BASE_PATH")
196202
if base_path:
197203
script_name = "/" + base_path
@@ -243,7 +249,7 @@ def handle_payload_v2(app, event, context):
243249

244250
script_name = get_script_name(headers, event.get("requestContext", {}))
245251

246-
path_info = event["rawPath"]
252+
path_info = get_path(event["rawPath"])
247253

248254
body = event.get("body", "")
249255
body = get_body_bytes(event, body)
@@ -294,7 +300,7 @@ def handle_lambda_integration(app, event, context):
294300

295301
script_name = get_script_name(headers, event)
296302

297-
path_info = event["requestPath"]
303+
path_info = get_path(event["requestPath"])
298304

299305
for key, value in event.get("path", {}).items():
300306
path_info = path_info.replace("{%s}" % key, value)

0 commit comments

Comments
 (0)