diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2016-12-12 17:37:30 +0100 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2016-12-29 03:09:58 +0100 |
commit | 0e027e6858022589ace11218ce102ce57499e5e6 (patch) | |
tree | 86204a4ae9694d764cf77cd4471f560470483f22 /src/leap/bitmask/core/web | |
parent | 58eed37a06da111b8b22378ad2511e8a793b1c69 (diff) |
[feature] better param error handling in rest api
Diffstat (limited to 'src/leap/bitmask/core/web')
-rw-r--r-- | src/leap/bitmask/core/web/api.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/leap/bitmask/core/web/api.py b/src/leap/bitmask/core/web/api.py index e8bd21e4..6c386b5d 100644 --- a/src/leap/bitmask/core/web/api.py +++ b/src/leap/bitmask/core/web/api.py @@ -2,6 +2,9 @@ import json from twisted.web.server import NOT_DONE_YET from twisted.web.resource import Resource +from twisted.logger import Logger + +log = Logger() class Api(Resource): @@ -16,6 +19,8 @@ class Api(Resource): command = request.uri.split('/')[2:] params = request.content.getvalue() if params: + # TODO sanitize this + # json.loads returns unicode strings and the rest of the code # expects strings. This 'str(param)' conversion can be removed # if we move to python3 @@ -24,6 +29,7 @@ class Api(Resource): d = self.dispatcher.dispatch(command) d.addCallback(self._write_response, request) + d.addErrback(log.error) return NOT_DONE_YET def _write_response(self, response, request): |