You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Middleware writers should access the original return of the handler, before serialization happens.
Current Behaviour
When writing your own middleware, you only get access to a serialized version of the handler response, and not the original. This introduces challenges when you want to manipulate the original response.
Code snippet
classMyMiddleware(BaseMiddlewareHandler):
defhandler(self, app: EventHandlerInstance, next_middleware: NextMiddleware) ->Response:
# Call the handler by calling the next middlewareresponse=next_middleware(app)
response.body# this should be the original response, not a serialized version
Possible Solution
Move the serialization as the last operation to be done before returning, after running all the middlewares.
Steps to Reproduce
See code snippet above
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.7
Packaging format used
PyPi
Debugging logs
No response
The text was updated successfully, but these errors were encountered:
Expected Behaviour
Middleware writers should access the original return of the handler, before serialization happens.
Current Behaviour
When writing your own middleware, you only get access to a serialized version of the handler response, and not the original. This introduces challenges when you want to manipulate the original response.
Code snippet
Possible Solution
Move the serialization as the last operation to be done before returning, after running all the middlewares.
Steps to Reproduce
See code snippet above
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.7
Packaging format used
PyPi
Debugging logs
No response
The text was updated successfully, but these errors were encountered: