20 lines
602 B
Python
20 lines
602 B
Python
from fastapi import APIRouter, HTTPException
|
|
|
|
from core.db import check_database
|
|
from schemas.health_schemas import HealthResponse
|
|
|
|
router = APIRouter(prefix="/health", tags=["health"])
|
|
|
|
|
|
@router.get("/live", response_model=HealthResponse)
|
|
def live_api():
|
|
return HealthResponse(status="ok")
|
|
|
|
|
|
# В отличие от live, ready зависит от PostgreSQL.
|
|
@router.get("/ready", response_model=HealthResponse)
|
|
def ready_api():
|
|
if not check_database():
|
|
raise HTTPException(status_code=503, detail="База данных недоступна")
|
|
return HealthResponse(status="ok")
|