SnipHunter API

Health

服务健康与依赖就绪。

Base URL https://api.sniphunter.com

OpenAPI JSON · 完整 Markdown

请求与响应中的 $ref 在 OpenAPI 的 components 中定义。

4 个接口

Health

GET/Root

{
  "responses": {
    "200": {
      "description": "Successful Response",
      "content": {
        "application/json": {
          "schema": {}
        }
      }
    }
  }
}
GET/api/v1/health/基础健康检查

返回应用的基本健康状态信息,用于快速检测应用是否正常运行。

{
  "responses": {
    "200": {
      "description": "应用健康",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/HealthResponse"
          },
          "example": {
            "status": "healthy",
            "version": "1.0.0",
            "timestamp": "2024-01-01T00:00:00Z"
          }
        }
      }
    }
  }
}
GET/api/v1/health/detailed详细健康检查

返回更详细的系统状态信息。

{
  "responses": {
    "200": {
      "description": "Successful Response",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/HealthResponse"
          }
        }
      }
    }
  }
}
GET/api/v1/health/ready就绪检查

检查所有依赖服务的连接状态,用于 Kubernetes 就绪探针。 返回各服务的状态: - **database**: PostgreSQL 数据库连接状态 - **redis**: Redis 缓存服务连接状态

{
  "responses": {
    "200": {
      "description": "所有服务就绪",
      "content": {
        "application/json": {
          "schema": {},
          "example": {
            "status": "ready",
            "checks": {
              "database": {
                "status": "healthy",
                "latency_ms": 5.23
              },
              "redis": {
                "status": "healthy",
                "latency_ms": 1.05
              }
            },
            "version": "1.0.0",
            "environment": "production",
            "timestamp": "2024-01-01T00:00:00Z"
          }
        }
      }
    },
    "503": {
      "description": "服务未就绪",
      "content": {
        "application/json": {
          "example": {
            "status": "not_ready",
            "checks": {
              "database": {
                "status": "unhealthy",
                "error": "Connection refused"
              },
              "redis": {
                "status": "healthy",
                "latency_ms": 1.05
              }
            },
            "version": "1.0.0",
            "environment": "production",
            "timestamp": "2024-01-01T00:00:00Z"
          }
        }
      }
    }
  }
}

数据模型

展开 components
{
  "schemas": {
    "HealthResponse": {
      "properties": {
        "success": {
          "type": "boolean",
          "title": "Success",
          "description": "操作是否成功",
          "default": true
        },
        "status": {
          "type": "string",
          "title": "Status",
          "description": "服务状态",
          "default": "healthy"
        },
        "version": {
          "type": "string",
          "title": "Version",
          "description": "服务版本",
          "default": "1.0.0"
        },
        "timestamp": {
          "type": "string",
          "title": "Timestamp",
          "description": "检查时间戳"
        }
      },
      "type": "object",
      "required": [
        "timestamp"
      ],
      "title": "HealthResponse",
      "description": "健康检查响应"
    }
  },
  "securitySchemes": {
    "HTTPBearer": {
      "type": "http",
      "scheme": "bearer"
    }
  }
}