24 lines
533 B
Python
24 lines
533 B
Python
|
|
"""Health/observability endpoints (§15)."""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from fastapi import APIRouter, Depends
|
||
|
|
from sqlalchemy import text
|
||
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||
|
|
|
||
|
|
import gogo
|
||
|
|
from gogo.db import get_session
|
||
|
|
|
||
|
|
router = APIRouter()
|
||
|
|
|
||
|
|
|
||
|
|
@router.get("/health")
|
||
|
|
async def health():
|
||
|
|
return {"status": "ok", "version": gogo.__version__}
|
||
|
|
|
||
|
|
|
||
|
|
@router.get("/health/db")
|
||
|
|
async def health_db(session: AsyncSession = Depends(get_session)):
|
||
|
|
await session.execute(text("SELECT 1"))
|
||
|
|
return {"status": "ok"}
|