From 5017c55ffcc02e3da0e710271e1c4796a2ed193e Mon Sep 17 00:00:00 2001 From: Vitor Hideyoshi Nakazone Batista Date: Fri, 16 Feb 2024 20:23:50 -0300 Subject: [PATCH] Adds Health Check API Endpoint --- storage_service/controller/__init__.py | 2 ++ .../controller/health_checker_controller.py | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 storage_service/controller/health_checker_controller.py diff --git a/storage_service/controller/__init__.py b/storage_service/controller/__init__.py index 164de38..73a712b 100644 --- a/storage_service/controller/__init__.py +++ b/storage_service/controller/__init__.py @@ -1,5 +1,6 @@ from storage_service.config.config_allowed_origins import get_allowed_origins from storage_service.controller.storage_controller import s3_router +from storage_service.controller.health_checker_controller import health_router from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware @@ -16,3 +17,4 @@ app.add_middleware( ) app.include_router(s3_router) +app.include_router(health_router) diff --git a/storage_service/controller/health_checker_controller.py b/storage_service/controller/health_checker_controller.py new file mode 100644 index 0000000..616b800 --- /dev/null +++ b/storage_service/controller/health_checker_controller.py @@ -0,0 +1,11 @@ +from fastapi_utils.cbv import cbv + +from fastapi_utils.inferring_router import InferringRouter + +health_router = InferringRouter() + +@cbv(health_router) +class HealthCheckerController: + @health_router.get("/health", status_code=200) + def health(self) -> dict[str, str]: + return {"status": "healthy"}