From 83afbaffb4c9c0d27c767a51a88d46c124cedd04 Mon Sep 17 00:00:00 2001 From: Deepak Kodihalli Date: Mon, 10 Apr 2017 06:37:19 -0500 Subject: rest_dbus: Add content_type Add the content_type property to indicate the content-type header for routes. As of now, POST and PUT expect 'application/json'. Change-Id: Id7641189c818a2b38382edff37b204c40fb15874 Signed-off-by: Deepak Kodihalli --- module/obmc/wsgi/apps/rest_dbus.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'module') diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py index e19d976..47dacaa 100644 --- a/module/obmc/wsgi/apps/rest_dbus.py +++ b/module/obmc/wsgi/apps/rest_dbus.py @@ -67,12 +67,13 @@ class RouteHandler(object): _require_auth = obmc.utils.misc.makelist(valid_user) _enable_cors = True - def __init__(self, app, bus, verbs, rules): + def __init__(self, app, bus, verbs, rules, content_type=''): self.app = app self.bus = bus self.mapper = obmc.mapper.Mapper(bus) self._verbs = obmc.utils.misc.makelist(verbs) self._rules = rules + self._content_type = content_type self.intf_match = obmc.utils.misc.org_dot_openbmc_match if 'GET' in self._verbs: @@ -211,10 +212,11 @@ class MethodHandler(RouteHandler): verbs = 'POST' rules = '/action/' request_type = list + content_type = 'application/json' def __init__(self, app, bus): super(MethodHandler, self).__init__( - app, bus, self.verbs, self.rules) + app, bus, self.verbs, self.rules, self.content_type) def find(self, path, method): busses = self.try_mapper_call( @@ -270,10 +272,11 @@ class MethodHandler(RouteHandler): class PropertyHandler(RouteHandler): verbs = ['PUT', 'GET'] rules = '/attr/' + content_type = 'application/json' def __init__(self, app, bus): super(PropertyHandler, self).__init__( - app, bus, self.verbs, self.rules) + app, bus, self.verbs, self.rules, self.content_type) def find(self, path, prop): self.app.instance_handler.setup(path) -- cgit v1.2.1