summaryrefslogtreecommitdiff
path: root/server/dispatcher.py
blob: fdec47a5b24573d80747254d7f305514dd4a9d37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import json
import cherrypy
from lib import uuid

class Dispatcher(object):
    def validate_uuid(self, uuid4):
        if not uuid.validate(uuid4):
            self.error(1, 'Invalid UUID in request: ' + str(uuid4))

    def error(self, code, message='An application error occurred'):
        raise cherrypy.HTTPError(400,
            json.dumps({'error': {'code': int(code), 'message': str(message)}})
        )

    def GET(self, id=None):
        raise cherrypy.HTTPError(405)

    def POST(self, id, status):
        raise cherrypy.HTTPError(405)

    def PUT(self):
        raise cherrypy.HTTPError(405)

    def DELETE(self):
        raise cherrypy.HTTPError(405)

    def PATCH(self):
        raise cherrypy.HTTPError(405)