Skip to content

Commit 5c77151

Browse files
šŸ“ add documentation to create scope function
1 parent 2b71225 commit 5c77151

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ā€Žmangum/adapter.pyā€Ž

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,20 @@ def __call__(self, event: dict, context: "LambdaContext") -> dict:
100100

101101
scope = self._create_scope(event, context)
102102
http_cycle = HTTPCycle(scope, text_mime_types=self.text_mime_types)
103-
104103
response = http_cycle(self.app, initial_body)
105104

106105
return response
107106

108107
def _create_scope(self, event: dict, context: "LambdaContext") -> Scope:
108+
"""Creates a scope object according to ASGI specification from a Lambda Event.
109+
110+
https://asgi.readthedocs.io/en/latest/specs/www.html#http-connection-scope
111+
112+
The event comes from various sources: AWS ALB, AWS API Gateway of different
113+
versions and configurations(multivalue header, etc).
114+
Thus, some heuristics is applied to guess an event type.
115+
116+
"""
109117
request_context = event["requestContext"]
110118

111119
if event.get("multiValueHeaders"):

0 commit comments

Comments
Ā (0)
⚔