]> git.cworth.org Git - turbot/commitdiff
Switch to parse the x-www-form-urlencoded data in Python
authorCarl Worth <cworth@cworth.org>
Mon, 12 Oct 2020 03:52:01 +0000 (20:52 -0700)
committerCarl Worth <cworth@cworth.org>
Mon, 12 Oct 2020 04:20:32 +0000 (21:20 -0700)
Previously, we were doing this in a mapping template within AWS,
but I decided that that mechanism was more trouble that it was
worth, (it was quite buried in AWS, hard to share across multiple
lambdas, and meanwhile this approach is a single line of code).

turbot_lambda/turbot_lambda.py

index d441565186ab563470778c603a08732417f4cece..f3d28f25f7abb6a0afde786d246c0c1ff29ee93c 100644 (file)
@@ -1,3 +1,4 @@
+from urllib.parse import parse_qs
 from turbot.rot import rot
 
 def turbot_lambda(event, context):
@@ -6,4 +7,10 @@ def turbot_lambda(event, context):
     Currently only calls into the rot() function but may become more
     sophisticated later on."""
 
-    return rot(event['text'])
+    body = parse_qs(event['body'])
+    result = rot(body['text'][0])
+
+    return {
+        'statusCode': 200,
+        'body': result
+    }