summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2024-03-25 20:26:30 +0100
committerxengineering <me@xengineering.eu>2024-03-25 20:27:16 +0100
commit9f1fc3ca35845a0fe5501f8a56646d6568e89e48 (patch)
treec38ade129c2237f5927db2bf06e3ed619a7a277d /main.go
parent7dd778cda189ea7debc7770a030fc831b9eab18b (diff)
downloadwebiot-9f1fc3ca35845a0fe5501f8a56646d6568e89e48.tar
webiot-9f1fc3ca35845a0fe5501f8a56646d6568e89e48.tar.zst
webiot-9f1fc3ca35845a0fe5501f8a56646d6568e89e48.zip
Make the parsed configuration a global variable
This removes the need to pass the configuration struct to every function.
Diffstat (limited to 'main.go')
-rw-r--r--main.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/main.go b/main.go
index 6d930b4..15fcc7a 100644
--- a/main.go
+++ b/main.go
@@ -15,7 +15,7 @@ var templates *template.Template
func main() {
configPath := parseFlags()
- c := parseConfig(configPath)
+ parseConfig(configPath)
var err error
templates, err = template.ParseFS(static, "templates/index.html")
@@ -23,14 +23,14 @@ func main() {
log.Fatal(err)
}
- http.HandleFunc("/", index(c.Devices))
+ http.HandleFunc("/", index(config.Devices))
http.HandleFunc("/api", api)
http.Handle("/static/", http.StripPrefix("/static/",
http.FileServer(http.FS(static))))
- fmt.Printf("Serving at http://%s\n", c.Web.Listen)
+ fmt.Printf("Serving at http://%s\n", config.Web.Listen)
- log.Fatal(http.ListenAndServe(c.Web.Listen.String(), nil))
+ log.Fatal(http.ListenAndServe(config.Web.Listen.String(), nil))
}
// parseFlags() handles command line interface (CLI) flags.