mirror of
https://github.com/quantum5/qlinks.git
synced 2025-04-24 10:41:57 -04:00
Add health check endpoint
This commit is contained in:
parent
7ff577fd0c
commit
1a60694112
|
@ -2,9 +2,10 @@ from functools import partial
|
||||||
|
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from qlinks.views import short_link
|
from qlinks.views import health_check, short_link
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', partial(short_link, path=''), name='short_link'),
|
path('', partial(short_link, path=''), name='short_link'),
|
||||||
|
path('api/health_check', health_check, name='health_check'),
|
||||||
path('<path:path>', short_link, name='short_link'),
|
path('<path:path>', short_link, name='short_link'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
|
||||||
from qlinks.models import Link
|
from qlinks.models import Link
|
||||||
|
@ -10,3 +10,8 @@ def short_link(request, path):
|
||||||
return HttpResponseRedirect(link, headers={
|
return HttpResponseRedirect(link, headers={
|
||||||
'X-Powered-By': settings.QLINKS_POWERED_BY
|
'X-Powered-By': settings.QLINKS_POWERED_BY
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def health_check(request):
|
||||||
|
Link.objects.exists()
|
||||||
|
return HttpResponse('qlinks seems to work!')
|
||||||
|
|
Loading…
Reference in a new issue