diff options
author | ache <ache@ache.one> | 2019-02-21 10:33:46 +0100 |
---|---|---|
committer | ache <ache@ache.one> | 2019-02-21 10:33:46 +0100 |
commit | dc29c7e989f8761d902e8ffcbc19c131f893303a (patch) | |
tree | 351d5385227cdadcdfc59315a9649122db27a36d /config/config.go | |
parent | Size normalisation (diff) |
Config package
Diffstat (limited to 'config/config.go')
-rw-r--r-- | config/config.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..b46b0e1 --- /dev/null +++ b/config/config.go @@ -0,0 +1,33 @@ +package config + +import ( + "encoding/json" + "io/ioutil" + "os" +) + +type config struct { + Hostnames []string `json:"host"` + Port int `json:"port"` + AllowLocalPath bool `json:"allow-local-path"` + Auth bool `json:"auth"` + RootPath string `json:"root-path"` +} + +var Config config + +func ReadConfig() error { + file, err := os.Open("config.json") + + if err != nil { + return err + } else { + defer file.Close() + } + + content, _ := ioutil.ReadAll(file) + + json.Unmarshal(content, &Config) + + return nil +} |