aboutsummaryrefslogtreecommitdiff
path: root/app/handlers/base.py
diff options
context:
space:
mode:
authorMilo Casagrande <milo.casagrande@linaro.org>2014-04-09 11:43:09 +0200
committerMilo Casagrande <milo.casagrande@linaro.org>2014-04-09 11:43:09 +0200
commit78c6aa581ac200e7ade087171016f348fbe4d68c (patch)
tree530319d7eaae8e5175287caff703ab212cc81ecb /app/handlers/base.py
parentb1563dbda3c93328d155fb051c00f40b4893bce8 (diff)
Make sure the status code is always included in the JSON response.
* Add the 'code' keywork to the JSON response, with the HTTP code. * Change the 'status' keyword in 'code' and make sure that all responses have it.
Diffstat (limited to 'app/handlers/base.py')
-rw-r--r--app/handlers/base.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/app/handlers/base.py b/app/handlers/base.py
index dcd810b..bd57cc8 100644
--- a/app/handlers/base.py
+++ b/app/handlers/base.py
@@ -139,7 +139,7 @@ class BaseHandler(RequestHandler):
status, message = 200, self._get_status_message(200)
self.set_status(status)
- self.write(dict(status=status, message=message))
+ self.write(dict(code=status, message=message))
self.finish()
def _get_callback(self, result):
@@ -150,6 +150,7 @@ class BaseHandler(RequestHandler):
at least the `result` key.
"""
result['result'] = dumps(result['result'])
+ result['code'] = 200
self.set_status(200)
self.write(result)
@@ -257,7 +258,7 @@ class BaseHandler(RequestHandler):
if status_message:
self.set_status(status_code)
- self.write(dict(status=status_code, message=status_message))
+ self.write(dict(code=status_code, message=status_message))
self.finish()
else:
super(BaseHandler, self).write_error(status_code)