From 4d065aa93ff87d021cd9475a1e8bb71a63a2131f Mon Sep 17 00:00:00 2001 From: Dmitry Afanasyev Date: Mon, 1 May 2023 03:13:50 +0300 Subject: [PATCH] add healthcheck url --- app/api/__init__.py | 0 app/api/system/__init__.py | 0 app/api/system/controllers.py | 15 +++++++++++++++ app/main.py | 4 ++-- app/routers.py | 7 ++++++- 5 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 app/api/__init__.py create mode 100644 app/api/system/__init__.py create mode 100644 app/api/system/controllers.py diff --git a/app/api/__init__.py b/app/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/api/system/__init__.py b/app/api/system/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/api/system/controllers.py b/app/api/system/controllers.py new file mode 100644 index 0000000..16a3204 --- /dev/null +++ b/app/api/system/controllers.py @@ -0,0 +1,15 @@ +from fastapi import APIRouter +from fastapi.responses import ORJSONResponse +from starlette import status + +router = APIRouter() + + +@router.get( + "/healthcheck", + name="system:healthcheck", + status_code=status.HTTP_200_OK, + summary="Healthcheck service", +) +async def healthcheck() -> ORJSONResponse: + return ORJSONResponse(content=None, status_code=status.HTTP_200_OK) diff --git a/app/main.py b/app/main.py index f5d4695..015986c 100644 --- a/app/main.py +++ b/app/main.py @@ -11,8 +11,8 @@ class Application: title='Health check bot', description='Bot which check all services are working', version='0.0.1', - docs_url=None, - redoc_url=None, + docs_url=f'{settings.WEBHOOK_PATH}/docs', + redoc_url=f'{settings.WEBHOOK_PATH}/redocs', openapi_url=f'{settings.WEBHOOK_PATH}/api/openapi.json', default_response_class=UJSONResponse, ) diff --git a/app/routers.py b/app/routers.py index b9ee391..ec4336a 100644 --- a/app/routers.py +++ b/app/routers.py @@ -1,4 +1,9 @@ from fastapi import APIRouter from fastapi.responses import ORJSONResponse -api_router = APIRouter(prefix="/api", default_response_class=ORJSONResponse) +from app.api.system.controllers import router as system_router + +api_router = APIRouter(prefix='/api', default_response_class=ORJSONResponse) + + +api_router.include_router(system_router, tags=['system'])