forked from mtusi2026/mtusi2026lab2
ЛР2: PostgreSQL, сессии (Basic + Bearer), Compose, миграции
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
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")
|
||||
Reference in New Issue
Block a user