(event_info)
| 149 | |
| 150 | |
| 151 | def process_lambda_payload_v2(event_info): |
| 152 | # See the new format documentation |
| 153 | # here: https://docs.aws.amazon.com/lambda/latest/dg/urls-invocation.html#urls-payloads |
| 154 | method = event_info["requestContext"]["http"]["method"] |
| 155 | headers = event_info["headers"] |
| 156 | if event_info.get("cookies"): |
| 157 | headers["cookie"] = "; ".join(event_info["cookies"]) |
| 158 | path = unquote(event_info["rawPath"]) |
| 159 | query = event_info.get("queryStringParameters", {}) |
| 160 | query_string = urlencode(query) if query else "" |
| 161 | # Systems calling the Lambda (other than API Gateway) may not provide the field requestContext |
| 162 | # Extract remote_user, authorizer if Authorizer is enabled |
| 163 | remote_user = None |
| 164 | authorizer = event_info["requestContext"].get("authorizer", None) |
| 165 | if authorizer: |
| 166 | if authorizer.get("lambda"): |
| 167 | # Need to add principalId manually to lambda authorizer response context |
| 168 | remote_user = authorizer["lambda"].get("principalId") |
| 169 | elif authorizer.get("iam"): |
| 170 | remote_user = authorizer["iam"].get("userArn") |
| 171 | return method, headers, path, query_string, remote_user, authorizer |
| 172 | |
| 173 | |
| 174 | def common_log(environ, response, response_time: Optional[int] = None): |
no outgoing calls
no test coverage detected