(event_info)
| 118 | |
| 119 | |
| 120 | def process_lambda_payload_v1(event_info): |
| 121 | method = event_info.get("httpMethod", None) |
| 122 | headers = merge_headers(event_info) or {} # Allow for the AGW console 'Test' button to work (Pull #735) |
| 123 | path = unquote(event_info["path"]) |
| 124 | # API Gateway and ALB both started allowing for multi-value querystring |
| 125 | # params in Nov. 2018. If there aren't multi-value params present, then |
| 126 | # it acts identically to 'queryStringParameters', so we can use it as a |
| 127 | # drop-in replacement. |
| 128 | # |
| 129 | # The one caveat here is that ALB will only include _one_ of |
| 130 | # queryStringParameters _or_ multiValueQueryStringParameters, which means |
| 131 | # we have to check for the existence of one and then fall back to the |
| 132 | # other. |
| 133 | if "multiValueQueryStringParameters" in event_info: |
| 134 | query = event_info["multiValueQueryStringParameters"] |
| 135 | query_string = urlencode(query, doseq=True) if query else "" |
| 136 | else: |
| 137 | query = event_info.get("queryStringParameters", {}) |
| 138 | query_string = urlencode(query) if query else "" |
| 139 | # Systems calling the Lambda (other than API Gateway) may not provide the field requestContext |
| 140 | # Extract remote_user, authorizer if Authorizer is enabled |
| 141 | authorizer, remote_user = None, None |
| 142 | if "requestContext" in event_info: |
| 143 | authorizer = event_info["requestContext"].get("authorizer", None) |
| 144 | if authorizer: |
| 145 | remote_user = authorizer.get("principalId") |
| 146 | elif event_info["requestContext"].get("identity"): |
| 147 | remote_user = event_info["requestContext"]["identity"].get("userArn") |
| 148 | return method, headers, path, query_string, remote_user, authorizer |
| 149 | |
| 150 | |
| 151 | def process_lambda_payload_v2(event_info): |
no test coverage detected