检查服务健康

探测当前运行实例能否访问数据库。健康时响应 200 和文本 OK。

GET/health
认证
公开,无需登录。
成功状态
200

请求参数

此操作无需提交参数。

请求示例

cURL
curl -i -X GET 'https://social2api.com/health'
Python
from urllib.error import HTTPError
from urllib.request import Request, urlopen

request = Request(
    "https://social2api.com/health",
    method="GET",
)
send = urlopen
try:
    with send(request) as response:
        print(response.status, response.read().decode("utf-8"))
except HTTPError as error:
    print(error.code, error.read().decode("utf-8"))
JavaScript
const response = await fetch("/health", {
  method: "GET",
});
console.log(response.status, await response.text());

响应

200 · 示例响应
OK
错误示例
Database unavailable
字段类型说明
bodystring健康时为 OK。

错误状态

HTTP原因与处理
503数据库不可用。

使用细节

  • 完整 Node 后端通过数据库的轻量查询验证连通性。