diff options
author | xengineering <mail2xengineering@protonmail.com> | 2021-06-11 10:36:20 +0200 |
---|---|---|
committer | xengineering <mail2xengineering@protonmail.com> | 2021-06-11 10:45:35 +0200 |
commit | d4e1f48ff12db48e9a9bdbd3253c1041328ca66d (patch) | |
tree | e76a950b5a249b410743f3f26849831452083d11 /src/web.go | |
parent | d6fa6b112451f10f505db886d0ed023b3b931814 (diff) | |
download | birdscan-d4e1f48ff12db48e9a9bdbd3253c1041328ca66d.tar birdscan-d4e1f48ff12db48e9a9bdbd3253c1041328ca66d.tar.zst birdscan-d4e1f48ff12db48e9a9bdbd3253c1041328ca66d.zip |
Implement Configuration with JSON
Diffstat (limited to 'src/web.go')
-rw-r--r-- | src/web.go | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -15,15 +15,20 @@ const ( APP_DATA = "/usr/share/birdscan" ) -func runServer() { +type webConfig struct { + BindAddress string `json:"bind_address"` + BindPort string `json:"bind_port"` +} + +func runServer(cfg *webConfig) { router := chi.NewRouter() router.Use(middleware.Logger) router.Get("/", indexHandler) router.Get("/css/birdscan.css", cssHandler) - log.Println("Binding to 'http://" + "127.0.0.1" + ":" + "8080" + "'") - log.Fatal(http.ListenAndServe("127.0.0.1" + ":" + "8080", router)) + log.Println("Binding to 'http://" + cfg.BindAddress + ":" + cfg.BindPort + "'") + log.Fatal(http.ListenAndServe(cfg.BindAddress + ":" + cfg.BindPort, router)) } func indexHandler(w http.ResponseWriter, r *http.Request) { |