some refactoring
Build / Build (push) Successful in 10s

This commit is contained in:
wt committed 2025-07-16 14:45:52 +07:00
1 parent 49f6415c30
commit f01755caa8
5 files changed
+168 -42

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
package server
import (
"dns_service/api"
"net/http"
)
func Configure() {
http.Handle("/", api.SpaHandler(http.FS(api.Frontend)))
http.HandleFunc("/api/settings", api.Settings)
http.HandleFunc("/api/settings/file", api.SettingsFile)
}
+29
View File
@@ -0,0 +1,29 @@
package server
import (
"log"
"net/http"
"os"
)
func Run() {
if os.Getenv("ENABLE_TLS") == "true" {
err := http.ListenAndServeTLS(
os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"),
os.Getenv("CERT_FILE"),
os.Getenv("KEY_FILE"),
nil,
)
if err != nil {
log.Fatal(err)
}
} else {
err := http.ListenAndServe(
os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"),
nil,
)
if err != nil {
log.Fatal(err)
}
}
}