Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

32 lines
588B

  1. package main
  2. import (
  3. "encoding/json"
  4. log "github.com/sirupsen/logrus"
  5. "io/ioutil"
  6. )
  7. type configuration struct {
  8. Host string
  9. Port string
  10. DocRoot string
  11. StaticUrl string
  12. StripPrefix string
  13. }
  14. var configFile = "config.json"
  15. var config = configuration{}
  16. func (m *configuration) readConfig() (e error) {
  17. log.Printf("read Path config from %s", configFile)
  18. body, e := ioutil.ReadFile(configFile)
  19. if e != nil {
  20. log.Fatal("Cannot read config from " + configFile)
  21. return
  22. }
  23. e = json.Unmarshal(body, m)
  24. //TODO: check config before proceed further
  25. return
  26. }