about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--config.toml1
-rw-r--r--internal/config/config.go7
-rw-r--r--internal/server/server.go2
3 files changed, 6 insertions, 4 deletions
diff --git a/config.toml b/config.toml
index 9b6a35a..9ecaa6e 100644
--- a/config.toml
+++ b/config.toml
@@ -1,4 +1,5 @@
 base_url = "https://searchix.alanpearce.eu"
+data_path = "./data"
 
 [content-security-policy]
 default-src = [
diff --git a/internal/config/config.go b/internal/config/config.go
index e9300ce..c721424 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -24,9 +24,10 @@ func (u *URL) UnmarshalText(text []byte) (err error) {
 }
 
 type Config struct {
-	BaseURL URL  `toml:"base_url"`
-	CSP     *CSP `toml:"content-security-policy"`
-	Headers map[string]string
+	BaseURL  URL    `toml:"base_url"`
+	DataPath string `toml:"data_path"`
+	CSP      *CSP   `toml:"content-security-policy"`
+	Headers  map[string]string
 }
 
 func GetConfig() (*Config, error) {
diff --git a/internal/server/server.go b/internal/server/server.go
index 76fbecb..db93092 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -183,7 +183,7 @@ func New(runtimeConfig *Config) (*Server, error) {
 	})
 
 	var nixosOptions = options.NixOptions{}
-	jsonFile, err := os.ReadFile(path.Join("data", "test.json"))
+	jsonFile, err := os.ReadFile(path.Join(config.DataPath, "test.json"))
 	if err != nil {
 		slog.Error(fmt.Sprintf("error reading json file: %v", err))
 	}