diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/config.go | 17 | ||||
-rw-r--r-- | config/config.json | 4 |
2 files changed, 17 insertions, 4 deletions
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 } |