From d1c19fc7efd02a22e7f612c0929443f6fc631cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9B=BE=E5=8D=97?= <615883576@qq.com> Date: Tue, 4 Jun 2024 11:52:57 +0800 Subject: [PATCH] add simple fake api for _ping (#34) --- main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/main.go b/main.go index 3bae8fe..27ffbc4 100644 --- a/main.go +++ b/main.go @@ -171,6 +171,7 @@ func AuthMiddleware(authToken string) gin.HandlerFunc { } func (s *ProxyService) InitRoutes(e *gin.Engine) { + e.GET("/_ping", s.pong) authToken := s.cfg.AuthToken // replace with your dynamic value as needed if authToken != "" { // 鉴权 @@ -185,6 +186,20 @@ func (s *ProxyService) InitRoutes(e *gin.Engine) { } } +type Pong struct { + Now int `json:"now"` + Status string `json:"status"` + Ns1 string `json:"ns1"` +} + +func (s *ProxyService) pong(c *gin.Context) { + c.JSON(http.StatusOK, Pong{ + Now: time.Now().Second(), + Status: "ok", + Ns1: "200 OK", + }) +} + func (s *ProxyService) completions(c *gin.Context) { ctx := c.Request.Context()