summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorLibravatar Terin Stock <terinjokes@gmail.com>2022-11-26 19:59:15 +0100
committerLibravatar Terin Stock <terinjokes@gmail.com>2022-11-26 23:51:25 +0100
commitf4ce6ac1be7b2817a8e02fc0e517d93ff9890d2e (patch)
tree9474949eb2a2f21e5276a72bd3acdb499c37b5a5 /config.go
parentinitial commit (diff)
downloadcgit-httpd-f4ce6ac1be7b2817a8e02fc0e517d93ff9890d2e.tar.xz
add initial version of cgit-httpd
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
+}