diff --git a/velping/__main__.py b/velping/__main__.py index fdb1460..209e254 100644 --- a/velping/__main__.py +++ b/velping/__main__.py @@ -98,6 +98,19 @@ def http_ping(service: HTTPServiceConfig) -> None: time.sleep(cfg.pinging.rate) +@app.get("/api/v1/status") +async def api_v1_up() -> dict: + rsp = {"healthy": True, "services": {}} + for name, record in uptime.items(): + if record[-1] == "I": + rsp["services"][name] = {"healthy": True} + else: + rsp["services"][name] = {"healthy": False} + rsp["healthy"] = False + + return rsp + + @app.get("/", response_class=HTMLResponse) async def root() -> str: template = templates.get_template("index.xht")