8000 Customize automatic API return types · flask-api/flask-api@9874a2f · GitHub
[go: up one dir, main page]

Skip to content

Commit 9874a2f

Browse files
committed
Customize automatic API return types
1 parent a0b0b34 commit 9874a2f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

flask_api/app.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# coding: utf8
22
from __future__ import unicode_literals
33
from flask import request, Flask, Blueprint
4-
from flask._compat import reraise, string_types, text_type
4+
from flask._compat import reraise, string_types
55
from flask_api.exceptions import APIException
66
from flask_api.request import APIRequest
77
from flask_api.response import APIResponse
@@ -55,13 +55,15 @@ def make_response(self, rv):
5555
headers, status_or_headers = status_or_headers, None
5656

5757
if not isinstance(rv, self.response_class):
58-
if isinstance(rv, (text_type, bytes, bytearray, list, dict)):
58+
if isinstance(rv, self.response_class.api_return_types):
5959
status = status_or_headers
6060
rv = self.response_class(rv, headers=headers, status=status)
6161
headers = status_or_headers = None
6262
else:
6363
rv = self.response_class.force_type(rv, request.environ)
6464

65+
if status_or_headers is not None:
66+
if isinstance(
6567
if status_or_headers is not None:
6668
if isinstance(status_or_headers, string_types):
6769
rv.status = status_or_headers

0 commit comments

Comments
 (0)
0