in src/commons/abstract_lambda.py [0:0]
def __call__(self, event: dict) -> ProcessedEvent:
try:
body = json.loads(event.get('body') or '{}')
except json.JSONDecodeError as e:
raise ResponseFactory(HTTPStatus.BAD_REQUEST).message(
f'Invalid request body: \'{e}\''
).exc()
rc = event.get('requestContext') or {}
return {
'method': HTTPMethod(event['httpMethod']),
'resource': Endpoint.match(rc['resourcePath']),
'path': event['path'],
'fullpath': rc['path'],
'cognito_username': deep_get(rc, ('authorizer', 'claims',
'cognito:username')),
'cognito_customer': deep_get(rc, ('authorizer', 'claims',
'custom:customer')),
'cognito_user_id': deep_get(rc, ('authorizer', 'claims', 'sub')),
'cognito_user_role': deep_get(rc, ('authorizer', 'claims',
'custom:role')),
'permission': None, # will be set later
'is_system': deep_get(rc, ('authorizer', 'claims',
'custom:is_system')) or False,
'body': body,
'query': dict(event.get('queryStringParameters') or {}),
'path_params': dict(event.get('pathParameters') or {})
}