Created
August 18, 2017 12:25
-
-
Save eprikazc/32bf9f182d030985cbca80c75aaf6589 to your computer and use it in GitHub Desktop.
Middleware to work around Sentry-DRF compatibility issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RequestBodyMiddleware(object): | |
def __init__(self, get_response): | |
self.get_response = get_response | |
def __call__(self, request): | |
""" | |
Access request.body before request. | |
We need it for request.body to still be accessible after request | |
for example while handling exceptions in Sentry | |
See https://github.com/encode/django-rest-framework/issues/4050 | |
""" | |
_ = request.body | |
response = self.get_response(request) | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment