From 16eac696e962fe9e18bbe615b12185724554ceb5 Mon Sep 17 00:00:00 2001 From: eeliu <27064129+eeliu@users.noreply.github.com> Date: Fri, 10 May 2024 09:17:33 +0800 Subject: [PATCH] docs(py): Guide for exclude url > user path route #609 --- testapps/django/mysite/mysite/settings.py | 3 ++- testapps/django/mysite/polls/middleware.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 testapps/django/mysite/polls/middleware.py diff --git a/testapps/django/mysite/mysite/settings.py b/testapps/django/mysite/mysite/settings.py index 33fa2ee0..4327fb81 100644 --- a/testapps/django/mysite/mysite/settings.py +++ b/testapps/django/mysite/mysite/settings.py @@ -48,8 +48,9 @@ set_agent("cd.dev.test.django", "cd.dev.test.py", 'tcp:dev-collector:10000', -1, 0, logging.DEBUG) + MIDDLEWARE = [ - 'pinpointPy.Django.DjangoMiddleWare', + 'polls.middleware.UserMiddleWare', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', diff --git a/testapps/django/mysite/polls/middleware.py b/testapps/django/mysite/polls/middleware.py new file mode 100644 index 00000000..5aedc399 --- /dev/null +++ b/testapps/django/mysite/polls/middleware.py @@ -0,0 +1,15 @@ +from pinpointPy.Django import DjangoMiddleWare + + +def UserMiddleWare(get_response): + + pinpoint_handle_request = DjangoMiddleWare(get_response) + + def user_request_route(request): + if request.path in ['/heart_check']: + response = get_response(request) + else: + response = pinpoint_handle_request(request) + return response + + return user_request_route