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)