Пример #1
0
 def get_body_as_json_object(self, name="JSON object"):
     """ Get the body argument as JSON object. """
     try:
         return tornado.escape.json_decode(self.request.body)
     except (JSONDecodeError, TypeError, ValueError) as e:
         raise ServiceBadRequestError(f"Invalid or missing {name} in request body") from e
Пример #2
0
 def get_query_argument(self, name: str, default: Optional[str] = UNDEFINED) -> Optional[str]:
     value = self.kvp.get(name, default)
     if value is UNDEFINED:
         raise ServiceBadRequestError(f'Missing query parameter "{name}"')
     return value