From d4e1f48ff12db48e9a9bdbd3253c1041328ca66d Mon Sep 17 00:00:00 2001 From: xengineering Date: Fri, 11 Jun 2021 10:36:20 +0200 Subject: Implement Configuration with JSON --- src/web.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/web.go') diff --git a/src/web.go b/src/web.go index b57c5f5..4306b2c 100644 --- a/src/web.go +++ b/src/web.go @@ -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) { -- cgit v1.2.3-70-g09d2