From 8b4b1bd3e9401e7fc3894a2a563d14380d8310db Mon Sep 17 00:00:00 2001 From: Donkie Date: Sun, 2 Jul 2023 22:55:29 +0200 Subject: [PATCH] Added a health-check endpoint --- spoolman/api/v1/models.py | 4 ++++ spoolman/api/v1/router.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/spoolman/api/v1/models.py b/spoolman/api/v1/models.py index d828fb8..87a150c 100644 --- a/spoolman/api/v1/models.py +++ b/spoolman/api/v1/models.py @@ -155,3 +155,7 @@ class Spool(BaseModel): lot_nr=item.lot_nr, comment=item.comment, ) + + +class HealthCheck(BaseModel): + status: str = Field(example="healthy") diff --git a/spoolman/api/v1/router.py b/spoolman/api/v1/router.py index 0d1a898..62c0955 100644 --- a/spoolman/api/v1/router.py +++ b/spoolman/api/v1/router.py @@ -32,6 +32,13 @@ async def itemnotfounderror_exception_handler(_request: Request, exc: ItemNotFou ) +# Add health check endpoint +@app.get("/health") +async def health() -> models.HealthCheck: + """Return a health check.""" + return {"status": "healthy"} + + app.include_router(filament.router) app.include_router(spool.router) app.include_router(vendor.router)