parsers.py 434 B

1234567891011121314
  1. from typing import cast
  2. import orjson
  3. from django.http import HttpRequest
  4. from ninja.parser import Parser
  5. from ninja.types import DictStrAny
  6. class EnvelopeParser(Parser):
  7. def parse_body(self, request: HttpRequest):
  8. if request.META.get("CONTENT_TYPE") == "application/x-sentry-envelope":
  9. return [orjson.loads(line) for line in request.readlines()]
  10. else:
  11. return orjson.loads(request.body)