summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorache <ache@ache.one>2019-02-21 10:33:46 +0100
committerache <ache@ache.one>2019-02-21 10:33:46 +0100
commitdc29c7e989f8761d902e8ffcbc19c131f893303a (patch)
tree351d5385227cdadcdfc59315a9649122db27a36d /config
parentSize normalisation (diff)
Config package
Diffstat (limited to 'config')
-rw-r--r--config/config.go33
-rw-r--r--config/config.json4
2 files changed, 37 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
+}
diff --git a/config/config.json b/config/config.json
new file mode 100644
index 0000000..2bd396d
--- /dev/null
+++ b/config/config.json
@@ -0,0 +1,4 @@
+{
+ "host":["localhost"],
+ "port": 8080
+}