Skip to content

Commit

Permalink
add support api gateway context
Browse files Browse the repository at this point in the history
  • Loading branch information
langovoi committed Dec 3, 2023
1 parent b39df70 commit fa06799
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion krddevdays/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import base64
import json

import dotenv
from django.core.wsgi import get_wsgi_application
Expand All @@ -11,7 +13,11 @@


def application(environ, start_response):
script_name = environ.get('HTTP_X_SCRIPT_NAME', '')
api_gateway_context_raw = base64.b64decode(environ.get('HTTP_X_YC_APIGATEWAY_OPERATION_CONTEXT', 'e30=')).decode('utf8')
print('api_gateway_context_raw', api_gateway_context_raw)
api_gateway_context = json.loads(api_gateway_context_raw.replace("'", '"'))
print('api_gateway_context', api_gateway_context)
script_name = environ.get('HTTP_X_SCRIPT_NAME', api_gateway_context.get('X-Script-Name', ''))
if script_name:
environ['SCRIPT_NAME'] = script_name
path_info = environ['PATH_INFO']
Expand Down

0 comments on commit fa06799

Please sign in to comment.