Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
refactor: convert ping to a CBV
Browse files Browse the repository at this point in the history
  • Loading branch information
hartungstenio committed Apr 27, 2024
1 parent cf0a591 commit 744c8a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/healthy/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# SPDX-License-Identifier: MIT
from django.urls import path

from .views import ping
from .views import PingView

app_name = "healthy"

urlpatterns = [
path("ping/", ping, name="ping"),
path("ping/", PingView.as_view(), name="ping"),
]
15 changes: 11 additions & 4 deletions src/healthy/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
from http import HTTPStatus

from django.http import HttpRequest, HttpResponse
from django.views.decorators.http import require_http_methods
from django.views import View


@require_http_methods(["GET"])
async def ping(request: HttpRequest) -> HttpResponse:
return HttpResponse("Pong", status=HTTPStatus.OK)
class PingView(View):
http_method_names = [
"get",
"head",
"options",
"trace",
]

async def get(self, request: HttpRequest) -> HttpResponse:
return HttpResponse("Pong", status=HTTPStatus.OK)

0 comments on commit 744c8a6

Please sign in to comment.