From: dyh Date: Mon, 20 Apr 2020 01:52:00 +0000 (+0800) Subject: fix bug: Failed to open admin url X-Git-Tag: 1.0.6~5 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=modeling%2Fetsicatalog.git;a=commitdiff_plain;h=9d63f079341419d875ac5e697cefde920d26c802 fix bug: Failed to open admin url Issue-ID: MODELING-355 Change-Id: I93057d2ef94beed1dfa132e4afc78511184e8c12 Signed-off-by: dyh --- diff --git a/catalog/middleware.py b/catalog/middleware.py index cd6aa8b..02d4740 100644 --- a/catalog/middleware.py +++ b/catalog/middleware.py @@ -11,12 +11,16 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. import uuid + from onaplogging.mdcContext import MDC from catalog.pub.config.config import FORWARDED_FOR_FIELDS, SERVICE_NAME class LogContextMiddleware(object): + def __init__(self, get_response): + self.get_response = get_response + # the last IP behind multiple proxies, if no exist proxies # get local host ip. def _getLastIp(self, request): @@ -58,3 +62,9 @@ class LogContextMiddleware(object): def process_response(self, request, response): MDC.clear() return response + + def __call__(self, request): + self.process_request(request) + response = self.get_response(request) + self.process_response(request, response) + return response diff --git a/catalog/settings.py b/catalog/settings.py index 0068dac..cbb90d7 100644 --- a/catalog/settings.py +++ b/catalog/settings.py @@ -80,13 +80,12 @@ TEMPLATES = [ }, ] -MIDDLEWARE_CLASSES = [ +MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'catalog.middleware.LogContextMiddleware',