Files
mtusi2026lab2/src/application/api/health/endpoints.py
T

29 lines
799 B
Python

from fastapi import APIRouter, Request, status
from domain import HealthSchema
from domain.errors import UnavailableError
health_router = APIRouter(prefix="/health", tags=["Health"])
@health_router.get(
"/live",
status_code=status.HTTP_200_OK,
response_model=HealthSchema,
)
async def liveness() -> HealthSchema:
"""Процесс жив и обрабатывает хттп"""
return HealthSchema()
@health_router.get(
"/ready",
status_code=status.HTTP_200_OK,
response_model=HealthSchema,
)
async def readiness(request: Request) -> HealthSchema:
"""Хранилище создано и приложение не завершается"""
if not getattr(request.app.state, "is_ready", False):
raise UnavailableError()
return HealthSchema()