Refactor NodeConfig handling to use a map

This commit is contained in:
2025-10-08 19:24:24 +02:00
parent 3418735204
commit 7f6725da96
8 changed files with 25 additions and 52 deletions

View File

@@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"llamactl/pkg/config"
"llamactl/pkg/instance"
"net/http"
"net/http/httputil"
@@ -170,15 +169,8 @@ func (h *Handler) RemoteOpenAIProxy(w http.ResponseWriter, r *http.Request, mode
if !exists {
// Find node configuration
var nodeConfig *config.NodeConfig
for i := range h.cfg.Nodes {
if h.cfg.Nodes[i].Name == nodeName {
nodeConfig = &h.cfg.Nodes[i]
break
}
}
if nodeConfig == nil {
nodeConfig, exists := h.cfg.Nodes[nodeName]
if !exists {
http.Error(w, fmt.Sprintf("Node %s not found", nodeName), http.StatusInternalServerError)
return
}