Skip to content

Commit 9b97c03

Browse files
authored
Merge pull request chaitin#191 from yokowu/feat-health
feat: 健康检测接口
2 parents 8b29448 + f1667ed commit 9b97c03

File tree

3 files changed

+46
-15
lines changed

3 files changed

+46
-15
lines changed

backend/docs/swagger.json

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -734,11 +734,14 @@
734734
},
735735
{
736736
"description": "代码文件信息",
737-
"name": "codeFiles",
737+
"name": "fileMetas",
738738
"in": "body",
739739
"required": true,
740740
"schema": {
741-
"$ref": "#/definitions/domain.CodeFiles"
741+
"type": "array",
742+
"items": {
743+
"$ref": "#/definitions/domain.FileMeta"
744+
}
742745
}
743746
}
744747
],
@@ -3340,6 +3343,30 @@
33403343
}
33413344
}
33423345
},
3346+
"/v1/health": {
3347+
"get": {
3348+
"description": "固定回包 `{\"code\": 0, \"data\": \"MonkeyCode\"}`",
3349+
"consumes": [
3350+
"application/json"
3351+
],
3352+
"produces": [
3353+
"application/json"
3354+
],
3355+
"tags": [
3356+
"OpenAIV1"
3357+
],
3358+
"summary": "健康检查",
3359+
"operationId": "health",
3360+
"responses": {
3361+
"200": {
3362+
"description": "OK",
3363+
"schema": {
3364+
"$ref": "#/definitions/web.Resp"
3365+
}
3366+
}
3367+
}
3368+
}
3369+
},
33433370
"/v1/models": {
33443371
"get": {
33453372
"description": "模型列表",
@@ -3840,17 +3867,6 @@
38403867
}
38413868
}
38423869
},
3843-
"domain.CodeFiles": {
3844-
"type": "object",
3845-
"properties": {
3846-
"files": {
3847-
"type": "array",
3848-
"items": {
3849-
"$ref": "#/definitions/domain.FileMeta"
3850-
}
3851-
}
3852-
}
3853-
},
38543870
"domain.CodeLanguageType": {
38553871
"type": "string",
38563872
"enum": [

backend/internal/openai/handler/v1/v1.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func NewV1Handler(
4949

5050
w.GET("/api/config", web.BindHandler(h.GetConfig), middleware.Auth())
5151
w.GET("/v1/version", web.BaseHandler(h.Version), middleware.Auth())
52+
w.GET("/v1/health", web.BaseHandler(h.HealthCheck))
5253

5354
g := w.Group("/v1", middleware.Auth())
5455
g.GET("/models", web.BaseHandler(h.ModelList))
@@ -201,3 +202,17 @@ func (h *V1Handler) GetConfig(c *web.Context, req domain.ConfigReq) error {
201202
}
202203
return c.JSON(http.StatusOK, resp)
203204
}
205+
206+
// HealthCheck 健康检查
207+
//
208+
// @Tags OpenAIV1
209+
// @Summary 健康检查
210+
// @Description 固定回包 `{"code": 0, "data": "MonkeyCode"}`
211+
// @ID health
212+
// @Accept json
213+
// @Produce json
214+
// @Success 200 {object} web.Resp{}
215+
// @Router /v1/health [get]
216+
func (h *V1Handler) HealthCheck(c *web.Context) error {
217+
return c.Success("MonkeyCode")
218+
}

backend/pkg/cli/cli.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const scriptPath = "./tools/dist/cli.cjs"
1818
// @Description 运行monkeycode-cli命令
1919
// @Accept json
2020
// @Produce json
21-
// @Param command index string true "命令"
21+
// @Param command path string true "命令"
2222
// @Param flag query string false "标志"
23-
// @Param fileMetas body domain.[]FileMeta true "代码文件信息"
23+
// @Param fileMetas body []domain.FileMeta true "代码文件信息"
2424
// @Success 200 {object} []domain.IndexResult "输出结果"
2525
// @Failure 500 {object} web.Resp "内部错误"
2626
// @Router /api/v1/cli/{command} [post]

0 commit comments

Comments
 (0)