summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2017-04-10 07:27:09 -0500
committerDeepak Kodihalli <dkodihal@in.ibm.com>2017-04-19 04:10:33 -0500
commitfb6cd48331cc1d8491a1887598f40fee7f5a097c (patch)
tree14b98a999ccad326185d4b88b1ab670660d24472
parent461367a561b4ab30561b426171cd1b569988e436 (diff)
downloadphosphor-rest-server-fb6cd48331cc1d8491a1887598f40fee7f5a097c.tar.gz
phosphor-rest-server-fb6cd48331cc1d8491a1887598f40fee7f5a097c.zip
rest_dbus: run Json format plugins conditionally
Run Json format verification plug-ins only if the content-type is 'application/json'. Change-Id: Ia6e089b94cc24fbd630042414335af7ce1ccd707 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
-rw-r--r--module/obmc/wsgi/apps/rest_dbus.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py
index 7ef4afd..e83d933 100644
--- a/module/obmc/wsgi/apps/rest_dbus.py
+++ b/module/obmc/wsgi/apps/rest_dbus.py
@@ -642,6 +642,11 @@ class JsonApiRequestPlugin(object):
abort(400, self.error_str % request.json)
def apply(self, callback, route):
+ content_type = getattr(
+ route.get_undecorated_callback(), '_content_type', None)
+ if self.json_type != content_type:
+ return callback
+
verbs = getattr(
route.get_undecorated_callback(), '_verbs', None)
if verbs is None:
@@ -664,8 +669,14 @@ class JsonApiRequestTypePlugin(object):
api = 2
error_str = "Expecting request format { 'data': %s }, got '%s'"
+ json_type = "application/json"
def apply(self, callback, route):
+ content_type = getattr(
+ route.get_undecorated_callback(), '_content_type', None)
+ if self.json_type != content_type:
+ return callback
+
request_type = getattr(
route.get_undecorated_callback(), 'request_type', None)
if request_type is None:
OpenPOWER on IntegriCloud