summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.go')
-rw-r--r--config.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/config.go b/config.go
new file mode 100644
index 0000000..61e666f
--- /dev/null
+++ b/config.go
@@ -0,0 +1,25 @@
+package main
+
+import (
+ "log"
+ "os"
+)
+
+type Config struct {
+ Port string
+ DB string
+}
+
+func LoadConfig() Config {
+ at := os.Getenv("STATSAT")
+ if at == "" {
+ log.Println("Defaulting to STATSAT=:8080")
+ at = ":8080"
+ }
+ db := os.Getenv("STATSDB")
+ if db == "" {
+ log.Println("Defaulting to STATSDB=./stats.db")
+ db = "./stats.db"
+ }
+ return Config{Port: at, DB: db}
+}