def __init__(self, data=None, status=200, content_type=None, converters=None):
default_content_type = 'application/json;charset=utf-8'
converters = dict(converters or [])
converters[default_content_type] = self.convert_application_json
if content_type is None:
# If the content type is not explicitly given, detect it
content_type = request.accept_mimetypes.best_match([default_content_type] + list(converters.keys()))
try:
converter = converters[content_type]
except KeyError:
converter = converters[default_content_type]
final_data = converter(data, status, content_type)
super(BaseApiResponse, self).__init__(final_data, content_type=content_type, status=status)
评论列表
文章目录