Skip to content

Commit

Permalink
Merge pull request #8 from SADiLaR/feature/health
Browse files Browse the repository at this point in the history
Feature: basic health endpoint
  • Loading branch information
friedelwolff authored Apr 11, 2024
2 parents 04c9708 + 9f9e017 commit f9194bd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@

urlpatterns = [
path("admin/", admin.site.urls),
path("_health/", views.health, name="health"),
path("", views.home, name="home"),
]
8 changes: 8 additions & 0 deletions app/app/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
from django.http import HttpResponse
from django.shortcuts import render


def health(request):
"""A very basic (minimal dependency) health endpoint."""
# If we want/need a health check for DB, cache, files, etc. that should
# probably be separate.
return HttpResponse("OK", content_type="text/plain")


def home(request):
template = "app/home.html"
context = {}
Expand Down
8 changes: 8 additions & 0 deletions app/general/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.test import Client, TestCase


class TestViews(TestCase):

def test_health(self):
response = Client().get("/_health/")
self.assertIn(b"OK", response.content)
5 changes: 5 additions & 0 deletions doc/urls.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
URL naming
==========

If a URL is not really for public consumption, prefix it with an undrescore,
e.g. "/_health/".

0 comments on commit f9194bd

Please sign in to comment.