Created
February 4, 2018 18:10
-
-
Save joepindar/f443b056d229cbbe7ea53902d5f7d8e6 to your computer and use it in GitHub Desktop.
AWS Lambda reflector function - prints and returns whatever it is sent from API Gateway
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+# Uses Python3 | |
+import json | |
+ | |
+# Generate a response for the browser | |
+def _generate_response(status, body): | |
+ return { | |
+ 'statusCode': status, | |
+ 'headers': { | |
+ 'Access-Control-Allow-Origin': '*', | |
+ 'X-Requested-With': '*', | |
+ 'Content-Type': 'application/json' | |
+ }, | |
+ 'body': json.dumps(body) | |
+ } | |
+ | |
+def lambda_handler(event, context=None): | |
+ print("event: {}".format(event)) | |
+ print("context: {}".format(context)) | |
+ _generate_response(200, event) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment