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>
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 @@
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 @@
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: