From 94fb8f24282be3aa41f275cb21d1eca76c1899a1 Mon Sep 17 00:00:00 2001 From: ache Date: Sun, 28 Feb 2021 21:59:58 +0100 Subject: Config + 1.16 + MultiSelection --- config/config.go | 17 ++++++++++++++--- config/config.json | 4 +++- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'config') diff --git a/config/config.go b/config/config.go index 48fbff4..ddf3f0a 100644 --- a/config/config.go +++ b/config/config.go @@ -9,15 +9,18 @@ import ( type config struct { Hostnames []string `json:"hosts"` Port int `json:"port"` - AllowLocalPath bool `json:"allow-local-path"` + AllowHidden bool `json:"allow-hidden"` Auth bool `json:"auth"` RootPath string `json:"root-path"` } var Config config -func ReadConfig() error { - file, err := os.Open("config.json") +func ReadConfig(path string) error { + if path == "" { + path = "config.json" + } + file, err := os.Open(path) if err != nil { return err @@ -31,3 +34,11 @@ func ReadConfig() error { return nil } + +func SetDefaultValue() { + Config.Hostnames = []string{"localhost"} + Config.Port = 8080 + Config.AllowHidden = false + Config.Auth = false + Config.RootPath = "." +} diff --git a/config/config.json b/config/config.json index 2bd396d..74dac99 100644 --- a/config/config.json +++ b/config/config.json @@ -1,4 +1,6 @@ { "host":["localhost"], - "port": 8080 + "port": 8080, + "allow-hidden": false, + "auth": true } -- cgit v1.2.3