From 654b4f517cdc99bdef8d68101d8223f086ac6c42 Mon Sep 17 00:00:00 2001 From: "sandro.meireles" Date: Mon, 26 Feb 2024 17:52:18 -0300 Subject: [PATCH] wip: ignore health check endpoint --- apip/middlewares/subdomain_mock.py | 9 ++++++++- apip/settings.py | 7 +++++++ apip/urls.py | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apip/middlewares/subdomain_mock.py b/apip/middlewares/subdomain_mock.py index 3ea6dce..00674af 100644 --- a/apip/middlewares/subdomain_mock.py +++ b/apip/middlewares/subdomain_mock.py @@ -9,11 +9,18 @@ from apip.fackers import get_faker +def is_health_check_endpoint(request: Request): + print(request.path) + return bool(request.path == f"/{settings.HEALTH_CHECK_ENDPOINT}") + + def get_request_subdomain(request: Request) -> str: + if is_health_check_endpoint(request): + return None + host: str = request.get_host() print(host) - host_parts = request.get_host().split(".") if host.startswith("127.0.0.1"): diff --git a/apip/settings.py b/apip/settings.py index d936fa0..3ac0c39 100644 --- a/apip/settings.py +++ b/apip/settings.py @@ -135,4 +135,11 @@ ], } +# Health check settings + +HEALTH_CHECK_ENDPOINT = "health-check" + + +# Mock settings + FAKER_CLASS = "application.fackers.CLIJSFFaker" diff --git a/apip/urls.py b/apip/urls.py index cd2cafa..b8faedb 100644 --- a/apip/urls.py +++ b/apip/urls.py @@ -10,7 +10,7 @@ urlpatterns = [ path("", lambda service: redirect("adminservices/service/", permanent=True)), - path("health-check", HealthCheckView.as_view()), + path(settings.HEALTH_CHECK_ENDPOINT, HealthCheckView.as_view()), path("admin", admin.site.urls), path("api/", include(testplans_urls)), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)