in chalice/local.py [0:0]
def create_lambda_event(self,
method: str,
path: str,
headers: Dict[str, str],
body: Optional[bytes] = None) -> EventType:
view_route = self._route_matcher.match_route(path)
event = {
'requestContext': {
'httpMethod': method,
'resourcePath': view_route.route,
'identity': {
'sourceIp': self.LOCAL_SOURCE_IP
},
'path': path.split('?')[0],
},
'headers': {k.lower(): v for k, v in headers.items()},
'pathParameters': view_route.captured,
'stageVariables': {},
}
if view_route.query_params:
event['multiValueQueryStringParameters'] = view_route.query_params
else:
# If no query parameters are provided, API gateway maps
# this to None so we're doing this for parity.
event['multiValueQueryStringParameters'] = None
if self._is_binary(headers) and body is not None:
event['body'] = base64.b64encode(body).decode('ascii')
event['isBase64Encoded'] = True
else:
event['body'] = body
return event