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

refactor: convert ping to a CBV #1

Merged
merged 1 commit into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)