Skip to content

Commit

Permalink
Add health check
Browse files Browse the repository at this point in the history
  • Loading branch information
liammulh committed Feb 5, 2025
1 parent ef3b68c commit 5216e0f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/config/middleware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""This module sets up custom middleware."""

# pylint: skip-file
# TODO(Liam): Don't skip lint in this module.

# TODO(Liam): Don't use deprecated `MiddlewareMixin`.
# https://docs.djangoproject.com/en/5.1/topics/http/middleware/#writing-your-own-middleware

from django.http import HttpResponse
from django.utils.deprecation import MiddlewareMixin


class HealthCheckMiddleware(MiddlewareMixin):
"""This is the health check that we use in AWS to make sure the HCI is still alive
and well."""

def process_request(self, request):
if request.META["PATH_INFO"] == "/ping/":
return HttpResponse("pong")
1 change: 1 addition & 0 deletions src/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
]

MIDDLEWARE = [
"config.middleware.HealthCheckMiddleware",
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
Expand Down

0 comments on commit 5216e0f

Please sign in to comment.