about summary refs log tree commit diff
path: root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.go')
-rw-r--r--config.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/config.go b/config.go
new file mode 100644
index 0000000..b64b574
--- /dev/null
+++ b/config.go
@@ -0,0 +1,44 @@
+// Copyright 2022 Terin Stock.
+// SPDX-License-Identifier: MPL-2.0
+
+package main
+
+import (
+	"os"
+
+	"olympos.io/encoding/edn"
+)
+
+type Config struct {
+	HTTP      HTTPConfig `edn:"http"`
+	CGit      CGitConfig `edn:"cgit"`
+	Git       GitConfig  `edn:"git"`
+	ReposRoot string     `edn:"repos-root"`
+}
+
+type HTTPConfig struct {
+	Host string `end:"host"`
+	Port int    `end:"port"`
+}
+
+type CGitConfig struct {
+	CGI        string `edn:"cgi"`
+	ConfigFile string `edn:"config-file"`
+	AssetsDir  string `edn:"assets-dir"`
+}
+
+type GitConfig struct {
+	CGI       string `edn:"cgi"`
+	ExportAll bool   `edn:"export-all"`
+}
+
+func readConfig(path string) (Config, error) {
+	cfg := Config{}
+	content, err := os.ReadFile(path)
+	if err != nil {
+		return cfg, err
+	}
+
+	err = edn.Unmarshal(content, &cfg)
+	return cfg, err
+}