init commit: create skeleton from lab1
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
from fastapi import APIRouter, Request
|
||||
|
||||
from app.core.database import check_database
|
||||
from app.errors.exceptions import unavailable
|
||||
from app.schemas.base import Health
|
||||
|
||||
router = APIRouter(prefix="/health", tags=["health"])
|
||||
|
||||
|
||||
@router.get("/live")
|
||||
async def liveness() -> Health:
|
||||
# Только «процесс жив»: БД намеренно не трогаем.
|
||||
return Health(status="ok")
|
||||
|
||||
|
||||
@router.get("/ready")
|
||||
def readiness(request: Request) -> Health:
|
||||
# Готовность = приложение может обслужить синхронный путь, а он требует БД.
|
||||
if not check_database(request.app.state.engine):
|
||||
raise unavailable()
|
||||
return Health(status="ok")
|
||||
Reference in New Issue
Block a user