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.