Skip to content

Commit 7f9c2ba

Browse files
authored
Merge pull request #8 from Moesif/fix-undefined-variable
Fix: Remove undefined variable
2 parents 323765c + 5269d01 commit 7f9c2ba

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

moesif_aws_lambda/middleware.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,13 @@ def process_body(self, body_wrapper):
132132
body = body_wrapper.get('body')
133133
transfer_encoding = 'json'
134134
except Exception as e:
135-
body = base64.b64encode(body_wrapper['body'].encode("utf-8"))
136-
return str(encodedBytes, "utf-8"), 'json'
135+
body = base64.b64encode(str(body_wrapper['body']).encode("utf-8"))
136+
if isinstance(body, str):
137+
return str(body).encode("utf-8"), 'base64'
138+
elif isinstance(body, (bytes, bytearray)):
139+
return str(body, "utf-8"), 'base64'
140+
else:
141+
return str(body), 'base64'
137142
return body, transfer_encoding
138143

139144
def before(self, event, context):

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# Versions should comply with PEP440. For a discussion on single-sourcing
2929
# the version across setup.py and the project code, see
3030
# https://packaging.python.org/en/latest/single_source_version.html
31-
version='1.0.5',
31+
version='1.0.6',
3232

3333
description='Moesif Middleware to automatically log API calls from AWS Lambda functions',
3434
long_description=long_description,

0 commit comments

Comments
 (0)