Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

Commit 9c5d7af

Browse files
committed
add support api gateway context
1 parent b39df70 commit 9c5d7af

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

krddevdays/wsgi.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import os
2+
import base64
3+
import json
24

35
import dotenv
46
from django.core.wsgi import get_wsgi_application
@@ -11,7 +13,11 @@
1113

1214

1315
def application(environ, start_response):
14-
script_name = environ.get('HTTP_X_SCRIPT_NAME', '')
16+
api_gateway_context_raw = base64.b64decode(environ.get('HTTP_X_YC_APIGATEWAY_OPERATION_CONTEXT', 'e30=')).decode('utf8')
17+
api_gateway_context_json = json.loads(api_gateway_context_raw)
18+
print('api_gateway_context', json.dumps(api_gateway_context_json))
19+
script_name = environ.get('HTTP_X_SCRIPT_NAME', api_gateway_context_json.get('X-Script-Name', ''))
20+
print('script_name', script_name)
1521
if script_name:
1622
environ['SCRIPT_NAME'] = script_name
1723
path_info = environ['PATH_INFO']

0 commit comments

Comments
 (0)