From f4ce6ac1be7b2817a8e02fc0e517d93ff9890d2e Mon Sep 17 00:00:00 2001 From: Terin Stock Date: Sat, 26 Nov 2022 19:59:15 +0100 Subject: add initial version of cgit-httpd --- config.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 config.go (limited to 'config.go') 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 +} -- cgit v1.2.3