mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-05 16:44:22 +00:00
30 lines
647 B
Go
30 lines
647 B
Go
package server
|
|
|
|
import (
|
|
"llamactl/pkg/config"
|
|
"llamactl/pkg/manager"
|
|
"net/http"
|
|
"net/http/httputil"
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
type Handler struct {
|
|
InstanceManager manager.InstanceManager
|
|
cfg config.AppConfig
|
|
httpClient *http.Client
|
|
remoteProxies map[string]*httputil.ReverseProxy // Cache of remote proxies by instance name
|
|
remoteProxiesMu sync.RWMutex
|
|
}
|
|
|
|
func NewHandler(im manager.InstanceManager, cfg config.AppConfig) *Handler {
|
|
return &Handler{
|
|
InstanceManager: im,
|
|
cfg: cfg,
|
|
httpClient: &http.Client{
|
|
Timeout: 30 * time.Second,
|
|
},
|
|
remoteProxies: make(map[string]*httputil.ReverseProxy),
|
|
}
|
|
}
|