Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
fix(aws_lambda.pyh): add support for http2 trigger (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranrib authored Jun 25, 2021
1 parent 85c633c commit 1df3f1e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions epsagon/triggers/aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ def __init__(self, start_time, event, context):
request_context.get('apiId')
)

self.resource['operation'] = event['httpMethod']
self.resource['operation'] = event.get(
'httpMethod',
request_context.get('http', {}).get('method', 'GET')
)

query_params = event.get(
'queryStringParameters',
Expand All @@ -323,10 +326,18 @@ def __init__(self, start_time, event, context):
'stage': request_context.get('stage', 'N/A'),
'query_string_parameters': query_params,
'path_parameters': path_params,
'path': event.get('resource', 'N/A'),
'path': event.get(
'resource',
request_context.get('http', {}).get('path', 'N/A')
),
}

add_data_if_needed(self.resource['metadata'], 'body', event['body'])
if 'body' in event:
add_data_if_needed(
self.resource['metadata'],
'body',
event['body']
)
add_data_if_needed(
self.resource['metadata'],
'headers',
Expand Down Expand Up @@ -534,7 +545,7 @@ def factory(start_time, event, context):
trigger_service = event['Records'][0][event_source].split(':')[-1]
elif 'requestContext' in event and 'elb' in event['requestContext']:
trigger_service = ElasticLoadBalancerLambdaTrigger.RESOURCE_TYPE
elif 'httpMethod' in event:
elif 'httpMethod' in event or 'routeKey' in event:
trigger_service = ProxyAPIGatewayLambdaTrigger.RESOURCE_TYPE
elif 'context' in event and 'http-method' in event['context']:
trigger_service = NoProxyAPIGatewayLambdaTrigger.RESOURCE_TYPE
Expand Down

0 comments on commit 1df3f1e

Please sign in to comment.