Merge pull request #191 from yokowu/feat-health

feat: 健康检测接口
This commit is contained in:
Yoko
2025-08-01 11:18:10 +08:00
committed by GitHub
3 changed files with 46 additions and 15 deletions

View File

@@ -734,11 +734,14 @@
},
{
"description": "代码文件信息",
"name": "codeFiles",
"name": "fileMetas",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/domain.CodeFiles"
"type": "array",
"items": {
"$ref": "#/definitions/domain.FileMeta"
}
}
}
],
@@ -3340,6 +3343,30 @@
}
}
},
"/v1/health": {
"get": {
"description": "固定回包 `{\"code\": 0, \"data\": \"MonkeyCode\"}`",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"OpenAIV1"
],
"summary": "健康检查",
"operationId": "health",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/web.Resp"
}
}
}
}
},
"/v1/models": {
"get": {
"description": "模型列表",
@@ -3840,17 +3867,6 @@
}
}
},
"domain.CodeFiles": {
"type": "object",
"properties": {
"files": {
"type": "array",
"items": {
"$ref": "#/definitions/domain.FileMeta"
}
}
}
},
"domain.CodeLanguageType": {
"type": "string",
"enum": [

View File

@@ -49,6 +49,7 @@ func NewV1Handler(
w.GET("/api/config", web.BindHandler(h.GetConfig), middleware.Auth())
w.GET("/v1/version", web.BaseHandler(h.Version), middleware.Auth())
w.GET("/v1/health", web.BaseHandler(h.HealthCheck))
g := w.Group("/v1", middleware.Auth())
g.GET("/models", web.BaseHandler(h.ModelList))
@@ -201,3 +202,17 @@ func (h *V1Handler) GetConfig(c *web.Context, req domain.ConfigReq) error {
}
return c.JSON(http.StatusOK, resp)
}
// HealthCheck 健康检查
//
// @Tags OpenAIV1
// @Summary 健康检查
// @Description 固定回包 `{"code": 0, "data": "MonkeyCode"}`
// @ID health
// @Accept json
// @Produce json
// @Success 200 {object} web.Resp{}
// @Router /v1/health [get]
func (h *V1Handler) HealthCheck(c *web.Context) error {
return c.Success("MonkeyCode")
}

View File

@@ -18,9 +18,9 @@ const scriptPath = "./tools/dist/cli.cjs"
// @Description 运行monkeycode-cli命令
// @Accept json
// @Produce json
// @Param command index string true "命令"
// @Param command path string true "命令"
// @Param flag query string false "标志"
// @Param fileMetas body domain.[]FileMeta true "代码文件信息"
// @Param fileMetas body []domain.FileMeta true "代码文件信息"
// @Success 200 {object} []domain.IndexResult "输出结果"
// @Failure 500 {object} web.Resp "内部错误"
// @Router /api/v1/cli/{command} [post]