Skip to content

Commit

Permalink
Add healthcheck endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
danniel committed Feb 19, 2024
1 parent e4a494d commit e98e4c5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion backend/donations/views/site.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from datetime import datetime

from django.shortcuts import redirect, render
from django.conf import settings
from django.http import HttpResponse
from django.shortcuts import redirect, render
from django.urls import reverse
from django.utils import timezone

Expand Down Expand Up @@ -100,3 +101,8 @@ class TermsHandler(BaseHandler):
def get(self, request, *args, **kwargs):
context = {"title": "Termeni și condiții"}
return render(request, self.template_name, context)


class HealthCheckHandler(BaseHandler):
def get(self, request, *args, **kwargs):
return HttpResponse("OK")
4 changes: 4 additions & 0 deletions backend/partners/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):
if request.path == "/health/":
logger.debug("Skipping healthcheck")
return self.get_response(request)

logger.debug("Request host %s", request.get_host())
try:
subdomain = PartnerDomainMiddleware.extract_subdomain(request.get_host(), settings.APEX_DOMAIN)
Expand Down
2 changes: 2 additions & 0 deletions backend/redirectioneaza/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
NoteHandler,
PolicyHandler,
TermsHandler,
HealthCheckHandler,
)


Expand All @@ -61,6 +62,7 @@
path("", HomePage.as_view(), name="home"),
path("ong/", ForNgoHandler.as_view(), name="ngo"),
path("pentru-ong-uri/", RedirectView.as_view(pattern_name="ngo", permanent=True)),
path("health/", HealthCheckHandler.as_view(), name="health-check"),
# backup in case of old urls. to be removed
path("asociatii/", NgoListHandler.as_view(), name="associations"),
path("termeni/", TermsHandler.as_view(), name="terms"),
Expand Down

0 comments on commit e98e4c5

Please sign in to comment.