Files
dns_service/main.go
T
wt efcb19aa2f
Build / Build (push) Successful in 32s
more optimizations
2025-07-07 22:40:06 +07:00

36 lines
698 B
Go

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,
)
}
}