From fb6cd48331cc1d8491a1887598f40fee7f5a097c Mon Sep 17 00:00:00 2001 From: Deepak Kodihalli Date: Mon, 10 Apr 2017 07:27:09 -0500 Subject: 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 --- module/obmc/wsgi/apps/rest_dbus.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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: -- cgit v1.2.1