From d2f07a824e9bb990b995900e8dce84c155c11032 Mon Sep 17 00:00:00 2001 From: Sakurasan <1173092237@qq.com> Date: Thu, 27 Apr 2023 22:23:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=94=99=E8=AF=AF=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- opencat.go | 3 ++- router/router.go | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/opencat.go b/opencat.go index 4cb2d53..0ffebbe 100644 --- a/opencat.go +++ b/opencat.go @@ -59,7 +59,8 @@ func main() { // 初始化用户 r.POST("/1/users/init", router.Handleinit) - r.Any("/v1/*proxypath", router.HandleProy) + // r.Any("/v1/*proxypath", router.HandleProy) + r.Match([]string{http.MethodGet, http.MethodPost}, "/v1/*proxypath", router.HandleProy) // r.POST("/v1/chat/completions", router.HandleProy) // r.GET("/v1/models", router.HandleProy) diff --git a/router/router.go b/router/router.go index 143053e..ceb1c08 100644 --- a/router/router.go +++ b/router/router.go @@ -358,7 +358,9 @@ func HandleProy(c *gin.Context) { req.Header = c.Request.Header if localuser { if store.KeysCache.ItemCount() == 0 { - c.JSON(http.StatusOK, gin.H{"error": "No Api-Key Available"}) + c.JSON(http.StatusBadGateway, gin.H{"error": gin.H{ + "message": "No Api-Key Available", + }}) return } req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", store.FromKeyCacheRandomItem()))