diff --git a/backend/common/src/health.py b/backend/common/src/health.py deleted file mode 100644 index 001a0216..00000000 --- a/backend/common/src/health.py +++ /dev/null @@ -1,11 +0,0 @@ -from django.http import HttpResponse - - -class HealthCheckMiddleware: - def __init__(self, get_response): - self.get_response = get_response - - def __call__(self, request): - if request.path == "/health": - return HttpResponse("ok") - return self.get_response(request) diff --git a/backend/common/urls.py b/backend/common/urls.py index e8a9fe94..92ed43b9 100644 --- a/backend/common/urls.py +++ b/backend/common/urls.py @@ -25,4 +25,9 @@ urlpatterns = [ views.NotificationView.as_view(), name="api-notification", ), + path( + "health/", + views.HealthCheck.as_view(), + name="api-health", + ), ] diff --git a/backend/common/views.py b/backend/common/views.py index 4a30b7e0..f7ba9973 100644 --- a/backend/common/views.py +++ b/backend/common/views.py @@ -20,6 +20,7 @@ from common.src.watched import WatchState from common.views_base import AdminOnly, ApiBaseView from drf_spectacular.utils import OpenApiResponse, extend_schema from rest_framework.response import Response +from rest_framework.views import APIView from task.tasks import check_reindex @@ -199,3 +200,11 @@ class NotificationView(ApiBaseView): response_serializer = NotificationSerializer(notifications, many=True) return Response(response_serializer.data) + + +class HealthCheck(APIView): + """health check view, no auth needed""" + + def get(self, request): + """health check, no auth needed""" + return Response("OK", status=200) diff --git a/backend/config/settings.py b/backend/config/settings.py index 8e9aab9b..1e2355ed 100644 --- a/backend/config/settings.py +++ b/backend/config/settings.py @@ -82,7 +82,6 @@ MIDDLEWARE = [ "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", - "common.src.health.HealthCheckMiddleware", ] ROOT_URLCONF = "config.urls"