检查服务状态码

执行同一连通性检查,只读取 HTTP 状态码。

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

请求参数

此操作无需提交参数。

请求示例

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

request = Request(
    "https://social2api.com/health",
    method="HEAD",
)
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: "HEAD",
});
console.log(response.status, await response.text());

响应

200 · 示例响应

无响应正文

错误状态

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

使用细节

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