summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2017-04-10 06:37:19 -0500
committerDeepak Kodihalli <dkodihal@in.ibm.com>2017-04-11 09:45:05 -0500
commit83afbaffb4c9c0d27c767a51a88d46c124cedd04 (patch)
tree720346f55d717c45964d55215cf03457d09b2f00
parent6075bb48f3d768c8f48148ca1357edcb79d0fef6 (diff)
downloadphosphor-rest-server-83afbaffb4c9c0d27c767a51a88d46c124cedd04.tar.gz
phosphor-rest-server-83afbaffb4c9c0d27c767a51a88d46c124cedd04.zip
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 <dkodihal@in.ibm.com>
-rw-r--r--module/obmc/wsgi/apps/rest_dbus.py9
1 files changed, 6 insertions, 3 deletions
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 = '<path:path>/action/<method>'
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 = '<path:path>/attr/<prop>'
+ 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)
OpenPOWER on IntegriCloud