forked from mtusi2026/mtusi2026lab2
feat: функционал первой лабы перенос
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user