From 6a73fd1931e3109df59c41aae9adb49bcf3e3cec Mon Sep 17 00:00:00 2001 From: Dylan Schultz <9121234+dylanschultzie@users.noreply.github.com> Date: Fri, 5 Jul 2024 16:00:57 -0700 Subject: [PATCH] Add switch for which health check to use Signed-off-by: Dylan Schultz <9121234+dylanschultzie@users.noreply.github.com> --- app/health_check_functions.py | 11 +++++++++++ app/routes.py | 16 +++------------- 2 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 app/health_check_functions.py diff --git a/app/health_check_functions.py b/app/health_check_functions.py new file mode 100644 index 0000000..d18d1c9 --- /dev/null +++ b/app/health_check_functions.py @@ -0,0 +1,11 @@ +from app.cosmos.cosmos import cosmos_health +from app.evm.ethereum import ethereum_health +from app.solana.solana import solana_health + +switch = { + "45": ethereum_health, + "57": cosmos_health, + "17": cosmos_health, + "90": cosmos_health, + "99": solana_health, +} diff --git a/app/routes.py b/app/routes.py index d8fb881..25fc52e 100644 --- a/app/routes.py +++ b/app/routes.py @@ -1,25 +1,15 @@ # routes.py from flask import Blueprint, request from app.common import parse_request -from app.cosmos.cosmos import cosmos_health -from app.evm.ethereum import ethereum_health -from app.solana.solana import solana_health +from app.health_check_functions import switch api = Blueprint("api", __name__) -health_check_functions = { - "45": ethereum_health, - "57": cosmos_health, - "17": cosmos_health, - "90": cosmos_health, - "99": solana_health, -} - @api.route("/health", methods=["GET"]) def health_check(): ip, port = parse_request(request) - rpc_type = port[:2] - health_check_function = health_check_functions.get(rpc_type) + rpc_type = port[-2:] + health_check_function = switch.get(rpc_type) if health_check_function: message, status = health_check_function(ip, port)