summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-12-31 05:16:29 +0100
committerAki <please@ignore.pl>2023-12-31 05:16:29 +0100
commita06e585bb3d3c67afd300cfd750d27fb3404a792 (patch)
treec5e28f2a34a3b9048b7b75dae9581663343e8356
parent08e9dc998ad1096c415c43c214731220c5ab34ff (diff)
downloadrudone-a06e585bb3d3c67afd300cfd750d27fb3404a792.zip
rudone-a06e585bb3d3c67afd300cfd750d27fb3404a792.tar.gz
rudone-a06e585bb3d3c67afd300cfd750d27fb3404a792.tar.bz2
Added stupid and naive configuration for port
-rw-r--r--main.go12
1 files changed, 11 insertions, 1 deletions
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() {