From a06e585bb3d3c67afd300cfd750d27fb3404a792 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 31 Dec 2023 05:16:29 +0100 Subject: Added stupid and naive configuration for port --- main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 6d92d32..036b47c 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "encoding/json" "log" "net/http" + "os" "github.com/gorilla/mux" ) @@ -43,7 +44,16 @@ func handleRequests() { router.HandleFunc("/entry", handleEntryPost).Methods("POST") router.HandleFunc("/entry", handleEntryOptions).Methods("OPTIONS") router.PathPrefix("/").Handler(http.FileServer(http.FS(content))) - log.Fatal(http.ListenAndServe(":8080", router)) + log.Fatal(http.ListenAndServe(configure(), router)) +} + +func configure() string { + at := os.Getenv("STATSAT") + if at == "" { + log.Println("Defaulting to STATSAT=:8080") + at = ":8080" + } + return at } func main() { -- cgit v1.1