sanbo commited on
Commit
8e0040d
·
1 Parent(s): d3b4319

update sth at 2025-10-10 19:57:43

Browse files
Files changed (1) hide show
  1. main.go +24 -24
main.go CHANGED
@@ -1479,30 +1479,30 @@ func handleChatCompletions(w http.ResponseWriter, r *http.Request) {
1479
 
1480
  debugLog("收到chat completions请求")
1481
 
1482
- // 验证API Key
1483
- authHeader := r.Header.Get("Authorization")
1484
- if !strings.HasPrefix(authHeader, "Bearer ") {
1485
- debugLog("缺少或无效的Authorization头")
1486
- http.Error(w, "Missing or invalid Authorization header", http.StatusUnauthorized)
1487
- // 记录请求统计
1488
- duration := time.Since(startTime)
1489
- recordRequestStats(startTime, path, http.StatusUnauthorized)
1490
- addLiveRequest(r.Method, path, http.StatusUnauthorized, duration, "", userAgent)
1491
- return
1492
- }
1493
-
1494
- apiKey := strings.TrimPrefix(authHeader, "Bearer ")
1495
- if apiKey != DEFAULT_KEY {
1496
- debugLog("无效的API key: %s", apiKey)
1497
- http.Error(w, "Invalid API key", http.StatusUnauthorized)
1498
- // 记录请求统计
1499
- duration := time.Since(startTime)
1500
- recordRequestStats(startTime, path, http.StatusUnauthorized)
1501
- addLiveRequest(r.Method, path, http.StatusUnauthorized, duration, "", userAgent)
1502
- return
1503
- }
1504
-
1505
- debugLog("API key验证通过")
1506
 
1507
  // 读取请求体
1508
  body, err := io.ReadAll(r.Body)
 
1479
 
1480
  debugLog("收到chat completions请求")
1481
 
1482
+ // // 验证API Key
1483
+ // authHeader := r.Header.Get("Authorization")
1484
+ // if !strings.HasPrefix(authHeader, "Bearer ") {
1485
+ // debugLog("缺少或无效的Authorization头")
1486
+ // http.Error(w, "Missing or invalid Authorization header", http.StatusUnauthorized)
1487
+ // // 记录请求统计
1488
+ // duration := time.Since(startTime)
1489
+ // recordRequestStats(startTime, path, http.StatusUnauthorized)
1490
+ // addLiveRequest(r.Method, path, http.StatusUnauthorized, duration, "", userAgent)
1491
+ // return
1492
+ // }
1493
+
1494
+ // apiKey := strings.TrimPrefix(authHeader, "Bearer ")
1495
+ // if apiKey != DEFAULT_KEY {
1496
+ // debugLog("无效的API key: %s", apiKey)
1497
+ // http.Error(w, "Invalid API key", http.StatusUnauthorized)
1498
+ // // 记录请求统计
1499
+ // duration := time.Since(startTime)
1500
+ // recordRequestStats(startTime, path, http.StatusUnauthorized)
1501
+ // addLiveRequest(r.Method, path, http.StatusUnauthorized, duration, "", userAgent)
1502
+ // return
1503
+ // }
1504
+
1505
+ // debugLog("API key验证通过")
1506
 
1507
  // 读取请求体
1508
  body, err := io.ReadAll(r.Body)