lambda-decorators
lambda-decorators copied to clipboard
`load_json_body` is triggered only when `event["body"]` is a string. Is there a good reason for it?
Because I only see reasons against it:
- Simply because a JSON can be passed also as bytes - hence
json.loads()method accepts types of bytes and bytearray as well. - If I decide to use this decorator on a handler it means I expect a JSON in the body, therefore I'd like it to return a 400 even when the input is not a string. This could be skipped it the body is already a dictionary.
I understand changing the logic to start acting on non-strings is most likely breaking. If a maintainer gives a green light, I can create a PR.
Also, I am curious of other opinions.