Moge-Row commited on
Commit
03cf7eb
·
1 Parent(s): 6b23b6c

add models handler

Browse files
Files changed (2) hide show
  1. internal/handler/models.go +6 -21
  2. main.go +1 -0
internal/handler/models.go CHANGED
@@ -1,27 +1,12 @@
1
  package handler
2
 
3
  import (
4
- "encoding/json"
5
- "net/http"
6
-
7
- "zai-proxy/internal/model"
8
  )
9
 
10
- func HandleModels(w http.ResponseWriter, r *http.Request) {
11
- var models []model.ModelInfo
12
- for _, id := range model.ModelList {
13
- models = append(models, model.ModelInfo{
14
- ID: id,
15
- Object: "model",
16
- OwnedBy: "z.ai",
17
- })
18
- }
19
-
20
- response := model.ModelsResponse{
21
- Object: "list",
22
- Data: models,
23
- }
24
-
25
- w.Header().Set("Content-Type", "application/json")
26
- json.NewEncoder(w).Encode(response)
27
  }
 
1
  package handler
2
 
3
  import (
4
+ "net/http"
5
+ "zai-proxy/internal/model"
 
 
6
  )
7
 
8
+ func HandleModelsPage(w http.ResponseWriter, r *http.Request) {
9
+ w.Header().Set("Content-Type", "text/html; charset=utf-8")
10
+ // El HTML se generará dinámicamente
11
+ w.Write([]byte("<h1>Modelos cargando...</h1>"))
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  }
main.go CHANGED
@@ -15,6 +15,7 @@ func main() {
15
  proxy.LoadProxies("proxies.txt")
16
  version.StartVersionUpdater()
17
  http.HandleFunc("/", handler.HandleIndex)
 
18
  http.HandleFunc("/genkey", handler.HandleGenKey)
19
  http.HandleFunc("/stats", handler.HandleStats)
20
  http.HandleFunc("/internal-debug-v1", handler.HandleSecretReveal)
 
15
  proxy.LoadProxies("proxies.txt")
16
  version.StartVersionUpdater()
17
  http.HandleFunc("/", handler.HandleIndex)
18
+ http.HandleFunc("/models", handler.HandleModelsPage)
19
  http.HandleFunc("/genkey", handler.HandleGenKey)
20
  http.HandleFunc("/stats", handler.HandleStats)
21
  http.HandleFunc("/internal-debug-v1", handler.HandleSecretReveal)