From d7d9be193276c41ced952fd9172e7ae8c995aa66 Mon Sep 17 00:00:00 2001
From: Carl Worth <cworth@cworth.org>
Date: Sun, 11 Oct 2020 20:52:01 -0700
Subject: [PATCH] Switch to parse the x-www-form-urlencoded data in Python

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 | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/turbot_lambda/turbot_lambda.py b/turbot_lambda/turbot_lambda.py
index d441565..f3d28f2 100644
--- a/turbot_lambda/turbot_lambda.py
+++ b/turbot_lambda/turbot_lambda.py
@@ -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
+    }
-- 
2.45.2