Skip to content

Commit ad1093f

Browse files
committed
Construct raw path from path parameters
1 parent fae504b commit ad1093f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

serverless_wsgi.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ def handle_lambda_integration(app, event, context):
311311

312312
path_info = event[u"requestPath"]
313313

314+
for key, value in event.get(u"path", {}).items():
315+
path_info = path_info.replace("{%s}" % key, value)
316+
path_info = path_info.replace("{%s+}" % key, value)
317+
314318
body = event.get("body", {})
315319
body = json.dumps(body) if body else ""
316320
body = get_body_bytes(event, body)

wsgi_handler_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ def event_lambda_integration():
994994
"q": "test"
995995
},
996996
"path": {
997-
"p": "path"
997+
"p": "path2"
998998
},
999999
"identity": {
10001000
"cognitoIdentityPoolId": "",
@@ -1011,7 +1011,7 @@ def event_lambda_integration():
10111011
"user": ""
10121012
},
10131013
"stageVariables": {},
1014-
"requestPath": "/some/path"
1014+
"requestPath": "/some/{p}"
10151015
}
10161016

10171017

@@ -1050,7 +1050,7 @@ def test_handler_lambda(mock_wsgi_app_file, mock_app, event_lambda_integration,
10501050
"HTTP_X_FORWARDED_FOR": "83.23.10.243, 130.166.149.164",
10511051
"HTTP_X_FORWARDED_PORT": "443",
10521052
"HTTP_X_FORWARDED_PROTO": "https",
1053-
"PATH_INFO": "/some/path",
1053+
"PATH_INFO": "/some/path2",
10541054
"QUERY_STRING": "q=test",
10551055
"REMOTE_ADDR": "83.23.100.243",
10561056
"REMOTE_USER": "testuser",

0 commit comments

Comments
 (0)