Add 'port' configuration option (fix #7)

This commit is contained in:
Noah 2024-03-08 15:55:13 -06:00
parent cc458e6381
commit 260df0914a
3 changed files with 5 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import (
// Configuration stores information retrieved from a configuration file // Configuration stores information retrieved from a configuration file
type Configuration struct { type Configuration struct {
port int
sites_dir string sites_dir string
} }
@ -21,6 +22,7 @@ func parseConfig(path string, config *Configuration) {
log.Panic("Failed to parse config:", err) log.Panic("Failed to parse config:", err)
} }
file.Close() file.Close()
config.port = int(data["port"].(float64)) // this conversion makes no sense
config.sites_dir = data["sites_dir"].(string) config.sites_dir = data["sites_dir"].(string)
} }

View File

@ -1,3 +1,4 @@
{ {
"port": 7575,
"sites_dir": "./sites" "sites_dir": "./sites"
} }

View File

@ -60,6 +60,6 @@ func main() {
go handler(data) // Run the handler go handler(data) // Run the handler
fmt.Fprint(w, "Received!") fmt.Fprint(w, "Received!")
}) })
log.Printf("Starting Lapis Deploy...") log.Printf("Starting Lapis Deploy on port %d...", configuration.port)
log.Fatal(http.ListenAndServe(":7575", nil)) log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", configuration.port), nil))
} }