From 322adbf4ca8112406353cacbccf49d49de2e08c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E8=B6=85=E8=B6=8A?= <993921@qq.com> Date: Mon, 4 Mar 2024 23:09:51 +0800 Subject: [PATCH] bugfix: healthz && swagger update --- docs/docs.go | 18 ++++++++++++++++-- docs/swagger.json | 13 +++++++++++++ docs/swagger.yaml | 8 ++++++++ rpc_server/api/health.go | 6 +----- rpc_server/routers/builder.go | 7 ++++++- 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 89631010..545cc0cb 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1,5 +1,4 @@ -// Package docs GENERATED BY SWAG; DO NOT EDIT -// This file was generated by swaggo/swag +// Package docs Code generated by swaggo/swag. DO NOT EDIT package docs import "github.com/swaggo/swag" @@ -46,6 +45,19 @@ const docTemplate = `{ } } }, + "/api/healthz": { + "get": { + "description": "Get Healthz", + "tags": [ + "Healthz" + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, "/api/v1/get-support-entrypoint": { "get": { "security": [ @@ -143,6 +155,8 @@ var SwaggerInfo = &swag.Spec{ Description: "", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", } func init() { diff --git a/docs/swagger.json b/docs/swagger.json index a50f25ab..fb2d35ee 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -34,6 +34,19 @@ } } }, + "/api/healthz": { + "get": { + "description": "Get Healthz", + "tags": [ + "Healthz" + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, "/api/v1/get-support-entrypoint": { "get": { "security": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index ab6e309b..783b7916 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -26,6 +26,14 @@ paths: description: OK tags: - Auth + /api/healthz: + get: + description: Get Healthz + responses: + "200": + description: OK + tags: + - Healthz /api/v1/get-support-entrypoint: get: consumes: diff --git a/rpc_server/api/health.go b/rpc_server/api/health.go index a2ec82ab..c29c7ede 100644 --- a/rpc_server/api/health.go +++ b/rpc_server/api/health.go @@ -10,10 +10,7 @@ import ( // Healthz // @Tags Healthz // @Description Get Healthz -// @Accept json -// @Product json -// @Param -// @Router /api/health [post,get,put,delete] +// @Router /api/healthz [get] // @Success 200 func Healthz(c *gin.Context) { response := models.GetResponse() @@ -23,5 +20,4 @@ func Healthz(c *gin.Context) { "time": time.Now(), "version": "v1.0.0", }) - response.Success(c) } diff --git a/rpc_server/routers/builder.go b/rpc_server/routers/builder.go index 72c77a93..091da4e5 100644 --- a/rpc_server/routers/builder.go +++ b/rpc_server/routers/builder.go @@ -16,7 +16,12 @@ func buildRouters(router *gin.Engine, routerMaps []RouterMap) { router.POST(routerMap.Url, routerMap.Func) } else if method == DELETE { router.DELETE(routerMap.Url, routerMap.Func) - } // ignore rest methods + } else if method == OPTIONS { + router.OPTIONS(routerMap.Url, routerMap.Func) + } else if method == HEAD { + router.HEAD(routerMap.Url, routerMap.Func) + } + // ignore rest methods } }