You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 line
639B

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