summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-10-06 19:26:02 +0300
committerLars Wirzenius <liw@liw.fi>2017-10-09 21:00:44 +0300
commitb4baa19b7d0668475ecd0c9e02be794322ab7f5f (patch)
tree507e668cf941fb1c6a2bd9072780a5b73942d15a
parent892b9d623f76d2ad140835ebbf635357ca0e0c85 (diff)
downloadqvisqve-b4baa19b7d0668475ecd0c9e02be794322ab7f5f.tar.gz
Add: optional header for a 200 response
-rw-r--r--qvarn/api.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/qvarn/api.py b/qvarn/api.py
index 926326f..33ba867 100644
--- a/qvarn/api.py
+++ b/qvarn/api.py
@@ -690,10 +690,13 @@ def response(status, body, headers): # pragma: no cover
)
-def ok_response(body): # pragma: no cover
- headers = {
- 'Content-Type': 'application/json',
- }
+def ok_response(body, headers=None): # pragma: no cover
+ if headers is None:
+ headers = {}
+ if 'Content-Type' not in headers:
+ headers.update({
+ 'Content-Type': 'application/json',
+ })
return response(apifw.HTTP_OK, body, headers)