summaryrefslogtreecommitdiff
path: root/config/config.go
blob: b46b0e162bc8e9dda1219f8bdaac770c9834a80c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
}