claude-web-chat/config.go
djuka 3283888738
All checks were successful
Tests / unit-tests (push) Successful in 51s
Inicijalna implementacija Claude Web Chat (Faza 1 - CLI mod)
- Login sa session cookie autentifikacijom
- Lista projekata iz filesystem-a
- Chat sa Claude CLI preko WebSocket-a
- Streaming NDJSON parsiranje iz CLI stdout-a
- Sesija zivi nezavisno od browsera (reconnect replay)
- Sidebar sa .md fajlovima i markdown renderovanjem
- Dark tema, htmx + Go templates
- 47 unit testova

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 05:03:40 +00:00

56 lines
1.1 KiB
Go

package main
import (
"encoding/json"
"fmt"
"os"
)
type APIConfig struct {
Key string `json:"key"`
Model string `json:"model"`
}
type Config struct {
Port int `json:"port"`
Mode string `json:"mode"`
ProjectsPath string `json:"projects_path"`
Username string `json:"username"`
Password string `json:"password"`
SessionSecret string `json:"session_secret"`
API APIConfig `json:"api"`
}
func LoadConfig(path string) (*Config, error) {
data, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("reading config: %w", err)
}
var cfg Config
if err := json.Unmarshal(data, &cfg); err != nil {
return nil, fmt.Errorf("parsing config: %w", err)
}
if cfg.Port == 0 {
cfg.Port = 9100
}
if cfg.Mode == "" {
cfg.Mode = "cli"
}
if cfg.ProjectsPath == "" {
cfg.ProjectsPath = "/root/projects"
}
if cfg.Username == "" {
return nil, fmt.Errorf("username is required")
}
if cfg.Password == "" {
return nil, fmt.Errorf("password is required")
}
if cfg.SessionSecret == "" {
return nil, fmt.Errorf("session_secret is required")
}
return &cfg, nil
}