package main import ( "dns_service/api" "log" "net/http" "os" "github.com/joho/godotenv" ) func main() { err := godotenv.Load("/etc/dns_service/dns_service.conf") if err != nil { log.Fatal("Error loading .env file") } http.Handle("/", api.SpaHandler(http.FS(api.Frontend))) http.HandleFunc("/api/settings", api.Settings) http.HandleFunc("/api/settings/file", api.SettingsFile) if os.Getenv("ENABLE_TLS") == "true" { http.ListenAndServeTLS( os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"), os.Getenv("CERT_FILE"), os.Getenv("KEY_FILE"), nil, ) } else { http.ListenAndServe( os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"), nil, ) } }