def get_response(self, environ): """Return a json response for a json request otherwise an html response """ resp = super(HTTPExceptionMixin, self).get_response(environ) if is_json_request(environ.get('HTTP_ACCEPT')): resp.mimetype = environ['HTTP_ACCEPT'] return resp
def get_body(self, environ=None): """Return the body with the right message in case of json request. """ body = super(HTTPExceptionMixin, self).get_body(environ) if is_json_request(environ.get('HTTP_ACCEPT')): body = dict(detail=self.body_message) body = encoder().encode(body) return body