Browse Source

Refactor: Add health endpoint

merge-requests/1/head
Drew Short 5 years ago
parent
commit
914a1c3d1d
  1. 3
      server/corvus/__init__.py
  2. 1
      server/corvus/api/__init__.py
  3. 17
      server/corvus/api/health_api.py

3
server/corvus/__init__.py

@ -81,9 +81,10 @@ def register_blueprints(app: Flask) -> None:
:param app:
:return:
"""
from corvus.api import AUTH_BLUEPRINT, USER_BLUEPRINT
from corvus.api import AUTH_BLUEPRINT, USER_BLUEPRINT, HEALTH_BLUEPRINT
app.register_blueprint(AUTH_BLUEPRINT)
app.register_blueprint(USER_BLUEPRINT)
app.register_blueprint(HEALTH_BLUEPRINT)
def register_error_handlers(app: Flask) -> None:

1
server/corvus/api/__init__.py

@ -1,3 +1,4 @@
"""API blueprint exports."""
from corvus.api.authentication_api import AUTH_BLUEPRINT
from corvus.api.user_api import USER_BLUEPRINT
from corvus.api.health_api import HEALTH_BLUEPRINT

17
server/corvus/api/health_api.py

@ -0,0 +1,17 @@
"""Endpoint to expose the health of the application"""
from flask import Blueprint
from corvus.api.decorators import return_json
from corvus.api.model import APIResponse, APIMessage
HEALTH_BLUEPRINT = Blueprint(
name='health', import_name=__name__, url_prefix='/health')
@HEALTH_BLUEPRINT.route('', methods=['GET'])
@return_json
def get_health() -> APIResponse:
return APIResponse(
APIMessage(True, 'Service is healthy'),
200
)
Loading…
Cancel
Save