From 260df0914a3e9ddc0c764edc6469ef794c263ee2 Mon Sep 17 00:00:00 2001 From: Noah Date: Fri, 8 Mar 2024 15:55:13 -0600 Subject: [PATCH] Add 'port' configuration option (fix #7) --- config.go | 2 ++ config.json | 1 + main.go | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config.go b/config.go index ff33fcc..3af4430 100644 --- a/config.go +++ b/config.go @@ -9,6 +9,7 @@ import ( // Configuration stores information retrieved from a configuration file type Configuration struct { + port int sites_dir string } @@ -21,6 +22,7 @@ func parseConfig(path string, config *Configuration) { log.Panic("Failed to parse config:", err) } file.Close() + config.port = int(data["port"].(float64)) // this conversion makes no sense config.sites_dir = data["sites_dir"].(string) } diff --git a/config.json b/config.json index 6b23d7b..f70fb4d 100644 --- a/config.json +++ b/config.json @@ -1,3 +1,4 @@ { + "port": 7575, "sites_dir": "./sites" } diff --git a/main.go b/main.go index b3509a7..9446f37 100644 --- a/main.go +++ b/main.go @@ -60,6 +60,6 @@ func main() { go handler(data) // Run the handler fmt.Fprint(w, "Received!") }) - log.Printf("Starting Lapis Deploy...") - log.Fatal(http.ListenAndServe(":7575", nil)) + log.Printf("Starting Lapis Deploy on port %d...", configuration.port) + log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", configuration.port), nil)) }