ctp-slack-bot / src /ctp_slack_bot /controllers /application_health_controller.py
LiKenun's picture
Refactor #6
f0fe0fd
raw
history blame contribute delete
822 Bytes
from aiohttp.web import json_response, Request, Response
from pydantic import ConfigDict
from typing import Self
from .base import ControllerBase, controller, get
from ctp_slack_bot.services import ApplicationHealthService
@controller("/health")
class ApplicationHealthController(ControllerBase):
"""
Application health reporting endpoints.
"""
model_config = ConfigDict(frozen=True)
application_health_service: ApplicationHealthService
@get("")
async def get_health(self: Self, request: Request) -> Response:
health_statuses = await self.application_health_service.get_health()
return json_response(dict(health_statuses), status=200 if all(health_statuses.values()) else 503)
@property
def name(self: Self) -> str:
return "application_health_controller"