Moge-Row commited on
Commit
f1fd149
路
1 Parent(s): a42f160

fix: routing alignment for stats and debug endpoints

Browse files
Files changed (1) hide show
  1. main.go +23 -23
main.go CHANGED
@@ -1,32 +1,32 @@
1
  package main
2
 
3
  import (
4
- "net/http"
5
-
6
- "zai-proxy/internal/config"
7
- "zai-proxy/internal/handler"
8
- "zai-proxy/internal/logger"
9
- "zai-proxy/internal/proxy"
10
- "zai-proxy/internal/version"
11
  )
12
 
13
  func main() {
14
- config.LoadConfig()
15
- logger.InitLogger()
16
- proxy.LoadProxies("proxies.txt")
17
- version.StartVersionUpdater()
 
 
 
 
 
 
 
 
 
 
18
 
19
- http.HandleFunc("/", handler.HandleIndex)
20
- http.HandleFunc("/genkey", handler.HandleGenKey)
21
- http.HandleFunc("/stats", handler.HandleStats)
22
- http.HandleFunc("/internal-debug-v1", handler.HandleSecretReveal)
23
- http.HandleFunc("/v1/models", handler.HandleModels)
24
- http.HandleFunc("/v1/chat/completions", handler.HandleChatCompletions)
25
- http.HandleFunc("/v1/messages", handler.HandleMessages)
26
 
27
- addr := ":" + config.Cfg.Port
28
- logger.LogInfo("Server starting on %s", addr)
29
- if err := http.ListenAndServe(addr, nil); err != nil {
30
- logger.LogError("Server failed: %v", err)
31
- }
32
  }
 
 
1
  package main
2
 
3
  import (
4
+ "log"
5
+ "net/http"
6
+ "os"
 
 
 
 
7
  )
8
 
9
  func main() {
10
+ // 1. Ruta para la Interfaz Visual (HOI4)
11
+ http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
12
+ http.ServeFile(w, r, "index.html")
13
+ })
14
+
15
+ // 2. Ruta para las Estad铆sticas (Ranking)
16
+ // Aseg煤rate de que esta funci贸n est茅 definida en keys.go o index.go
17
+ http.HandleFunc("/stats", StatsHandler)
18
+
19
+ // 3. Ruta de Depuraci贸n Privada
20
+ http.HandleFunc("/internal-debug-v1", DebugHandler)
21
+
22
+ // 4. Proxy V1 (SillyTavern, etc)
23
+ // http.HandleFunc("/v1/", ProxyHandler)
24
 
25
+ port := os.Getenv("PORT")
26
+ if port == "" { port = "7860" }
 
 
 
 
 
27
 
28
+ log.Printf("Servidor operativo en puerto %s", port)
29
+ if err := http.ListenAndServe(":"+port, nil); err != nil {
30
+ log.Fatal(err)
 
 
31
  }
32
+ }