--- a/hooks-queue.py Wed Aug 24 12:13:29 2016 +0800
+++ b/hooks-queue.py Wed Aug 24 19:29:28 2016 +0800
from tornado.ioloop import IOLoop
from tornado.options import define, options
-from tornado.web import Application, RequestHandler, URLSpec
+from tornado.web import Application, HTTPError, RequestHandler, URLSpec
from candolint.utils import lookup_option, timestamp
return self.application.rconn
+ def parse_json_payload(self):
+ return json.loads(self.request.body)
+ raise HTTPError(400, 'malformed JSON')
def push(self, base, changes):
class BitbucketHookHandler(BaseHookHandler):
- payload = json.loads(self.request.body)
+ payload = self.parse_json_payload()
'url': payload['repository']['links']['html']['href'],
'scm': payload['repository']['scm'],
self.finish({'result': 'pong'})
- payload = json.loads(self.request.body)
+ payload = self.parse_json_payload()
'url': payload['repository']['html_url'],