summaryrefslogtreecommitdiffstats
path: root/module/obmc/wsgi
diff options
context:
space:
mode:
authorJayanth Othayoth <ojayanth@in.ibm.com>2017-06-29 05:45:07 -0500
committerJayanth Othayoth <ojayanth@in.ibm.com>2017-07-06 22:48:29 -0500
commit1444fd8c9e9b0807b4f3682236bec7cb3eedeebf (patch)
tree59e426027db1e54ea84fc2225a8200ab6316373e /module/obmc/wsgi
parent0b62edfb4555bd78d17f6b7b13fe36ee8c443998 (diff)
downloadphosphor-rest-server-1444fd8c9e9b0807b4f3682236bec7cb3eedeebf.tar.gz
phosphor-rest-server-1444fd8c9e9b0807b4f3682236bec7cb3eedeebf.zip
rest_dbus: run JSON response format plugin conditionally
Run JSON response format verification plug-in only if the content-type is 'application/json'. Change-Id: I032b32193f05a68bf695a6c6c51fccfaba9b197a Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
Diffstat (limited to 'module/obmc/wsgi')
-rw-r--r--module/obmc/wsgi/apps/rest_dbus.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py
index 5cb1a56..f6188b6 100644
--- a/module/obmc/wsgi/apps/rest_dbus.py
+++ b/module/obmc/wsgi/apps/rest_dbus.py
@@ -233,10 +233,11 @@ class RouteHandler(object):
class DirectoryHandler(RouteHandler):
verbs = 'GET'
rules = '<path:path>/'
+ content_type = 'application/json'
def __init__(self, app, bus):
super(DirectoryHandler, self).__init__(
- app, bus, self.verbs, self.rules)
+ app, bus, self.verbs, self.rules, self.content_type)
def find(self, path='/'):
return self.try_mapper_call(
@@ -252,10 +253,11 @@ class DirectoryHandler(RouteHandler):
class ListNamesHandler(RouteHandler):
verbs = 'GET'
rules = ['/list', '<path:path>/list']
+ content_type = 'application/json'
def __init__(self, app, bus):
super(ListNamesHandler, self).__init__(
- app, bus, self.verbs, self.rules)
+ app, bus, self.verbs, self.rules, self.content_type)
def find(self, path='/'):
return self.try_mapper_call(
@@ -271,10 +273,11 @@ class ListNamesHandler(RouteHandler):
class ListHandler(RouteHandler):
verbs = 'GET'
rules = ['/enumerate', '<path:path>/enumerate']
+ content_type = 'application/json'
def __init__(self, app, bus):
super(ListHandler, self).__init__(
- app, bus, self.verbs, self.rules)
+ app, bus, self.verbs, self.rules, self.content_type)
def find(self, path='/'):
return self.try_mapper_call(
@@ -882,6 +885,7 @@ class JsonApiResponsePlugin(object):
''' Emits responses in the OpenBMC json api format. '''
name = 'json_api_response'
api = 2
+ json_type = "application/json"
@staticmethod
def has_body():
@@ -891,6 +895,11 @@ class JsonApiResponsePlugin(object):
app.install_error_callback(self.error_callback)
def apply(self, callback, route):
+ content_type = getattr(
+ route.get_undecorated_callback(), '_content_type', None)
+ if self.json_type != content_type:
+ return callback
+
def wrap(*a, **kw):
data = callback(*a, **kw)
if self.has_body():
OpenPOWER on IntegriCloud